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;
int n, L, i, w[151000], ed, b, e;
long long Res;
int main(){
scanf("%d%d", &n, &L);
for (i = 1; i <= n; i++){
scanf("%d", &w[i]);
}
sort(w + 1, w + n + 1);
ed = -2100000000;
for (i = 1; i < n; i++){
if (w[i] + L < w[i + 1] - L)continue;
b = w[i + 1] - L, e = w[i] + L;
if (e <= ed)continue;
if (ed < b)ed = b;
Res += e - ed;
ed = e;
}
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... |