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;
const int maxn = 500005;
int n, t;
int a[maxn];
void read()
{
cin >> n >> t;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
}
}
void solve()
{
int mn = t, mx = 0;
for (int i = 1; i <= n; ++i)
{
int rem = a[i] % t;
if (rem > t / 2) rem = t - rem;
mn = min(mn, rem);
mx = max(mx, rem);
}
cout << max((mn + mx) / 2 - mn, mx - (mx + mn) / 2) << "\n";
}
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
read();
solve();
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... |