#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pq priority_queue
using namespace std;
constexpr ll M = 1e9+7;
ll n, t;
inline ll mod(ll a){
return ((a%t)+t)%t;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> t;
vector<ll> ok(n);
for(int i = 0; i < n; i++){
cin >> ok[i];
ok[i] = mod(ok[i]);
}
sort(ok.begin(), ok.end());
deque<ll> git;
for(auto k: ok) git.pb(k);
ll score = M;
for(int i = 0; i <= n+1; i++){
score = min(M, git.back()-git.front());
git.pb(git.front()+t);
git.pop_front();
}
cout << score << '\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... |