#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, t;
cin >> n >> t;
vector<int> a(n);
for (auto & x: a) {
cin >> x;
x %= t;
}
sort(a.begin(), a.end());
int ans = 1e9;
for (int i = 0; i < n; ++i) {
int x = a[i], y = a[(i + 1) % n];
if (x > y) x -= t;
assert(x <= y);
ans = min(ans, (t - (y - x) + 1) / 2);
}
if (a[0] == a.back()) ans = 0;
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... |