#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2308 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2308 KB |
Output isn't correct |
3 |
Correct |
0 ms |
2308 KB |
Output is correct |
4 |
Correct |
0 ms |
2308 KB |
Output is correct |
5 |
Correct |
0 ms |
2308 KB |
Output is correct |
6 |
Correct |
0 ms |
2308 KB |
Output is correct |
7 |
Correct |
0 ms |
2308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2308 KB |
Output is correct |
2 |
Correct |
0 ms |
2308 KB |
Output is correct |
3 |
Correct |
0 ms |
2308 KB |
Output is correct |
4 |
Correct |
0 ms |
2308 KB |
Output is correct |
5 |
Correct |
0 ms |
2308 KB |
Output is correct |
6 |
Correct |
0 ms |
2308 KB |
Output is correct |
7 |
Correct |
0 ms |
2308 KB |
Output is correct |
8 |
Correct |
0 ms |
2308 KB |
Output is correct |
9 |
Correct |
0 ms |
2308 KB |
Output is correct |
10 |
Correct |
0 ms |
2308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2308 KB |
Output is correct |
2 |
Correct |
44 ms |
2308 KB |
Output is correct |
3 |
Correct |
35 ms |
2308 KB |
Output is correct |
4 |
Correct |
19 ms |
2308 KB |
Output is correct |
5 |
Correct |
46 ms |
2308 KB |
Output is correct |
6 |
Correct |
28 ms |
2308 KB |
Output is correct |
7 |
Correct |
25 ms |
2308 KB |
Output is correct |
8 |
Correct |
62 ms |
2308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
61 ms |
2308 KB |
Output isn't correct |
2 |
Correct |
40 ms |
2308 KB |
Output is correct |
3 |
Incorrect |
62 ms |
2308 KB |
Output isn't correct |
4 |
Correct |
18 ms |
2308 KB |
Output is correct |
5 |
Correct |
5 ms |
2308 KB |
Output is correct |
6 |
Correct |
47 ms |
2308 KB |
Output is correct |
7 |
Correct |
49 ms |
2308 KB |
Output is correct |
8 |
Incorrect |
40 ms |
2308 KB |
Output isn't correct |
9 |
Incorrect |
51 ms |
2308 KB |
Output isn't correct |
10 |
Incorrect |
34 ms |
2308 KB |
Output isn't correct |
11 |
Correct |
29 ms |
2308 KB |
Output is correct |
12 |
Correct |
41 ms |
2308 KB |
Output is correct |
13 |
Correct |
28 ms |
2308 KB |
Output is correct |
14 |
Correct |
39 ms |
2308 KB |
Output is correct |
15 |
Correct |
16 ms |
2308 KB |
Output is correct |