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;
int a[150010];
long long ans,s,e,t=-1e9;
int main(){
int i,n,l;
scanf("%d%d",&n,&l);
for(i=0;i<n;++i)scanf("%d",a+i);
sort(a,a+n);
for(i=1;i<n;++i){
s=a[i]-l,e=a[i-1]+l;
if(s<e)ans+=e-max(s,t),t=e;
}
printf("%lld",ans);
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... |