이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |