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;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef vector<vector<ll>> vll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define ms memset
#define fi first
#define se second
ll MOD = 998244353;
ll power(ll base, ll n){
base %= MOD;
if (n==0) return 1;
ll halfn = power(base,n/2);
if (n%2==0) return (halfn*halfn)%MOD;
return (((halfn*halfn)%MOD)*base)%MOD;
}
void solve(){
int n,T; cin>>n>>T;
vi a(n); FOR(i,0,n) cin>>a[i];
FOR(i,0,n) a[i]%=T;
sort(a.begin(), a.end());
int ans = a[n-1]-a[0];
FOR(i,0,n-1){
ans = min(ans, T+a[i]-a[i+1]);
}
cout<<(ans+1)/2<<"\n";
}
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int TC = 1; //cin>>TC;
while (TC--){
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... |