#include <bits/stdc++.h>
using namespace std;
#define debug(v) cerr<<#v" = "<<(v)<<"\n"
#define fst first
#define snd second
#define gcd(x,y) __gcd(x,y);
#define OnlineJudge(s) freopen((s".in"),"r",stdin); freopen((s".out"),"w",stdout);
#define fastIO() cin.tie(0)->sync_with_stdio(0);cin.exceptions(cin.failbit);
#define boolsolve() cout<<(solve()?"Yes":"No");
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vpll=vector<pll>;
using vvll=vector<vll>;
const ll INF=1e9+100;
const ll MOD=1e9+7;
const ll MAXN=2e5+100;
ll fexp(ll a,ll b,ll m=MOD){
ll r=1;
for(a%=m;b;b>>=1,a=(a*a)%m)if(b&1)r=(r*a)%m;
return r;
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
void solve(){
ll n, t, ans;
cin >> n >> t;
vll A(n);
for(int i=0; i<n; i++){
cin >> A[i];
A[i]%=t;
}
sort(A.begin(),A.end()); ans=A[n-1]-A[0];
for(int i=0; i<n-1; i++) ans=min(ans,t-A[i+1]+A[i]);
cout << (ans+1)/2;
}
int main(){
fastIO()
//OnlineJudge("")
ll t=1;
//cin >> t;
while(t--){
solve();
//cout << "\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... |