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 <bitset>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#define pb push_back
#define MOD 1000000007
#define NMAX 200001
#define nl '\n'
#define INF 1e18
#define pii1 pair<int, pair<int,int>> (1,(1,2));
#define pii pair<int,int>
#define tpl tuple<int,int,int,int,int>
#define int long long
using namespace std;
ifstream fin("data.in");
ofstream fout("data.out");
/*
====================DEMONSTRATION======================
=========================END===========================
*/
int n,t;
vector<int>v;
signed main() {
cin>>n>>t;
v.resize(n+1);
for(int i=1;i<=n;++i)
{
int x;
cin>>x;
v[i]=x%t;
}
sort(v.begin()+1,v.end());
int mini=INF;
mini=min(mini,(v[n]-v[1]));
for(int i=2;i<=n;++i)
{
mini=min(mini,t-(v[i]-v[i-1]));
}
cout<<(mini+1)/2;
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... |