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;
#define lld long long
int N;
lld a[150010],L;
lld ans;
int main(){
int i;
lld e,s;
//freopen("input.txt","r",stdin);
scanf("%d %lld",&N,&L);
for(i=1; i<=N; i++) scanf("%lld",&a[i]);
sort(a+1,a+N+1);
for(i=2; i<=N; i++){
e = a[i-1]+L;
s = a[i]-L;
if(e <= s) continue;
if(i > 2) s = max(s,a[i-2]+L);
ans += (e-s);
}
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... |