This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, t; cin >> n >> t;
vector<int> nums(n);
for (auto &a : nums) {
cin >> a;
a %= t;
}
sort(nums.begin(), nums.end());
if (nums[0] == nums[n - 1]) {
cout << 0 << endl; return 0;
}
// find largest gap in the numbers, then it is optimal to choose the
// opposite point of that gap
int best = t;
for (int i = 0; i < n; i ++) {
int gap = (nums[(i + 1) % n] - nums[i] + t) % t;
int kk = t - gap;
// cout << kk << endl;
best = min(best, (kk + 1) / 2);
}
cout << best << endl;
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... |