#include <bits/stdc++.h>
using namespace std;
long long ans;
int a[150010];
int main(){
int i,n,l,s,e,t=-1e9;
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 |
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 |
Incorrect |
0 ms |
2308 KB |
Output isn't 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 |
18 ms |
2308 KB |
Output is correct |
2 |
Correct |
28 ms |
2308 KB |
Output is correct |
3 |
Correct |
0 ms |
2308 KB |
Output is correct |
4 |
Correct |
42 ms |
2308 KB |
Output is correct |
5 |
Correct |
41 ms |
2308 KB |
Output is correct |
6 |
Correct |
43 ms |
2308 KB |
Output is correct |
7 |
Correct |
27 ms |
2308 KB |
Output is correct |
8 |
Correct |
18 ms |
2308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
62 ms |
2308 KB |
Output isn't correct |
2 |
Correct |
30 ms |
2308 KB |
Output is correct |
3 |
Correct |
47 ms |
2308 KB |
Output is correct |
4 |
Correct |
29 ms |
2308 KB |
Output is correct |
5 |
Correct |
19 ms |
2308 KB |
Output is correct |
6 |
Correct |
0 ms |
2308 KB |
Output is correct |
7 |
Correct |
36 ms |
2308 KB |
Output is correct |
8 |
Correct |
36 ms |
2308 KB |
Output is correct |
9 |
Correct |
32 ms |
2308 KB |
Output is correct |
10 |
Incorrect |
61 ms |
2308 KB |
Output isn't correct |
11 |
Correct |
28 ms |
2308 KB |
Output is correct |
12 |
Incorrect |
41 ms |
2308 KB |
Output isn't correct |
13 |
Incorrect |
41 ms |
2308 KB |
Output isn't correct |
14 |
Incorrect |
59 ms |
2308 KB |
Output isn't correct |
15 |
Correct |
61 ms |
2308 KB |
Output is correct |