#include <stdio.h>
#include <algorithm>
#define MIN -1000000001
using namespace std;
int n,l,lamp[150001];
int main (void)
{
int i,cnt=0,prv=MIN;
scanf("%d %d",&n,&l);
for(i=0;i<n;i++){
scanf("%d",&lamp[i]);
}
sort(lamp,lamp+n);
for(i=1;i<n;i++){
if(lamp[i-1]+l>max(prv,lamp[i]-l)){
cnt+=lamp[i-1]+l-max(prv,lamp[i]-l);
prv=lamp[i-1]+l;
}
}
printf("%d\n",cnt);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1668 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1668 KB |
Output isn't correct |
3 |
Correct |
0 ms |
1668 KB |
Output is correct |
4 |
Correct |
0 ms |
1668 KB |
Output is correct |
5 |
Correct |
0 ms |
1668 KB |
Output is correct |
6 |
Correct |
0 ms |
1668 KB |
Output is correct |
7 |
Correct |
0 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1668 KB |
Output is correct |
2 |
Correct |
0 ms |
1668 KB |
Output is correct |
3 |
Correct |
0 ms |
1668 KB |
Output is correct |
4 |
Correct |
0 ms |
1668 KB |
Output is correct |
5 |
Correct |
0 ms |
1668 KB |
Output is correct |
6 |
Correct |
0 ms |
1668 KB |
Output is correct |
7 |
Correct |
0 ms |
1668 KB |
Output is correct |
8 |
Correct |
0 ms |
1668 KB |
Output is correct |
9 |
Correct |
0 ms |
1668 KB |
Output is correct |
10 |
Correct |
0 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
1668 KB |
Output is correct |
2 |
Correct |
32 ms |
1668 KB |
Output is correct |
3 |
Correct |
27 ms |
1668 KB |
Output is correct |
4 |
Correct |
45 ms |
1668 KB |
Output is correct |
5 |
Correct |
50 ms |
1668 KB |
Output is correct |
6 |
Correct |
23 ms |
1668 KB |
Output is correct |
7 |
Correct |
2 ms |
1668 KB |
Output is correct |
8 |
Correct |
18 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1668 KB |
Output is correct |
2 |
Incorrect |
52 ms |
1668 KB |
Output isn't correct |
3 |
Incorrect |
38 ms |
1668 KB |
Output isn't correct |
4 |
Correct |
19 ms |
1668 KB |
Output is correct |
5 |
Correct |
24 ms |
1668 KB |
Output is correct |
6 |
Correct |
29 ms |
1668 KB |
Output is correct |
7 |
Correct |
28 ms |
1668 KB |
Output is correct |
8 |
Correct |
32 ms |
1668 KB |
Output is correct |
9 |
Correct |
42 ms |
1668 KB |
Output is correct |
10 |
Correct |
43 ms |
1668 KB |
Output is correct |
11 |
Correct |
0 ms |
1668 KB |
Output is correct |
12 |
Incorrect |
42 ms |
1668 KB |
Output isn't correct |
13 |
Incorrect |
42 ms |
1668 KB |
Output isn't correct |
14 |
Correct |
34 ms |
1668 KB |
Output is correct |
15 |
Incorrect |
51 ms |
1668 KB |
Output isn't correct |