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<stdio.h>
#include<algorithm>
using namespace std;
long long int n, m;
long long int a[1000000];
long long int res;
int main()
{
int i, j, k, l;
scanf("%lld %lld",&n,&m);
for(i=0;i<n;i++){scanf("%lld",&a[i]);a[i]-=m;}
sort(a,a+n);
m=2*m;
long long int si=a[0];
long long int ei=a[0]+m;
for(i=1;i<n;i++)
{
// printf("%d %d %d\n",si,ei,a[i]);
if(si<a[i])si=a[i];
if(ei>si){res += ei-si; si=ei;}
ei=a[i]+m;
}
printf("%lld\n",res);
}
# | 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... |