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 pair = std::array<int, 2>;
using ll = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::vector<int> v(n);
for (int i = 0; i < n; i++) {
std::cin >> v[i];
v[i] %= m;
}
std::sort(v.begin(), v.end());
int min = 1e9 + 1;
for (int i = 0; i < n; i++) {
int a = v[i], b = v[(i + 1) % n];
if (a == b) continue;
b -= m;
int mid = (a + b)/2;
min = std::min(min, std::max({
std::abs(mid - v[0]),
std::abs(mid - b),
std::abs(mid - a)
}));
}
std::cout << (min > 1e9 ? 0 : min) << '\n';
}
# | 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... |