#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T>
using ordered_set = tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class U>
using ordered_map = tree<T, U, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
#define ll long long
#define MOD 1000000007
#define MAXN 2e5
#define SIZE 314
#define pb push_back
ll power(ll a, ll b){
if (b == 0) return 1;
ll res = power(a, b / 2);
if (b % 2 == 1) return res * res % MOD * a % MOD;
return res * res % MOD;
// if (b % 2 == 1) return res * res * a;
// return res * res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, t;
cin >> n >> t;
vector<int> nums(n);
int minNum = 1e9, maxNum = 1;
for (int i = 0; i < n; i++){
cin >> nums[i];
nums[i] %= t;
minNum = min(minNum, nums[i]);
maxNum = max(maxNum, nums[i]);
}
int ans = (maxNum + minNum + 1) / 2;
for (int i = 0; i < n; i++){
if (nums[i] <= t / 2){
minNum = max(minNum, nums[i] + t);
}
}
ans = min(ans, (minNum - maxNum + 1) / 2);
cout << ans << "\n";
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |