This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
vector<int> vt;
cin >> n >> k;
for (int i = 1; i <= n; i++){
int t; cin >> t;
vt.push_back(t % k);
}
sort(vt.begin(), vt.end());
int ans = (vt.back() - vt[0] + 1) / 2;
for (int i = 1; i < vt.size(); i++)
ans = min(ans, (vt[i - 1] + k - vt[i] + 1) / 2);
cout << ans << '\n';
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:23:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for (int i = 1; i < vt.size(); i++)
| ~~^~~~~~~~~~~
# | 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... |