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 <cstdio>
#include <algorithm>
using namespace std;
int N, X[160000];
long long L, a=-0xFFFFFFFF, b=-0xFFFFFFFFF, sum=0;
int main()
{
int i,inp;
scanf("%d%lld",&N,&L);
for(i=0;i<N;++i) scanf("%d",X+i);
sort(X,X+N);
for(i=0;i<N;++i){
if(b<X[i]-L){
a=X[i]-L;
b=X[i]+L;
}
else{
sum+=b-max(a,X[i]-L);
a=b;
b=X[i]+L;
}
}
printf("%lld",sum);
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... |