#include <stdio.h>
#include <algorithm>
using namespace std;
int n,l;
long long sum;
long long slight[300000],elight[300000];
int main()
{
scanf("%d %d",&n, &l);
int i;
for(i = 1 ; i <= n ; i++){
scanf("%lld",&slight[i]);
slight[i]-=l;
}
sort(slight+1,slight+1+n);
for(i = 1 ; i <= n ; i++){
elight[i]=slight[i]+l*2;
}
int s=slight[1],x=elight[1];
for(i = 2 ; i <= n ; i++){
if(s<slight[i])s=slight[i];
if(s<=x){
sum+=x-s;
s=x;
}
x=elight[i];
}
printf("%lld",sum);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5772 KB |
Output is correct |
2 |
Correct |
0 ms |
5772 KB |
Output is correct |
3 |
Correct |
0 ms |
5772 KB |
Output is correct |
4 |
Correct |
0 ms |
5772 KB |
Output is correct |
5 |
Correct |
0 ms |
5772 KB |
Output is correct |
6 |
Correct |
0 ms |
5772 KB |
Output is correct |
7 |
Correct |
0 ms |
5772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5772 KB |
Output is correct |
2 |
Correct |
0 ms |
5772 KB |
Output is correct |
3 |
Correct |
0 ms |
5772 KB |
Output is correct |
4 |
Correct |
0 ms |
5772 KB |
Output is correct |
5 |
Correct |
0 ms |
5772 KB |
Output is correct |
6 |
Correct |
0 ms |
5772 KB |
Output is correct |
7 |
Correct |
0 ms |
5772 KB |
Output is correct |
8 |
Correct |
0 ms |
5772 KB |
Output is correct |
9 |
Correct |
0 ms |
5772 KB |
Output is correct |
10 |
Correct |
0 ms |
5772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
5772 KB |
Output is correct |
2 |
Correct |
29 ms |
5772 KB |
Output is correct |
3 |
Correct |
3 ms |
5772 KB |
Output is correct |
4 |
Correct |
33 ms |
5772 KB |
Output is correct |
5 |
Correct |
31 ms |
5772 KB |
Output is correct |
6 |
Correct |
18 ms |
5772 KB |
Output is correct |
7 |
Correct |
34 ms |
5772 KB |
Output is correct |
8 |
Correct |
31 ms |
5772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
5772 KB |
Output is correct |
2 |
Correct |
24 ms |
5772 KB |
Output is correct |
3 |
Correct |
42 ms |
5772 KB |
Output is correct |
4 |
Correct |
22 ms |
5772 KB |
Output is correct |
5 |
Correct |
0 ms |
5772 KB |
Output is correct |
6 |
Correct |
48 ms |
5772 KB |
Output is correct |
7 |
Correct |
21 ms |
5772 KB |
Output is correct |
8 |
Correct |
40 ms |
5772 KB |
Output is correct |
9 |
Correct |
38 ms |
5772 KB |
Output is correct |
10 |
Correct |
9 ms |
5772 KB |
Output is correct |
11 |
Correct |
25 ms |
5772 KB |
Output is correct |
12 |
Correct |
41 ms |
5772 KB |
Output is correct |
13 |
Correct |
38 ms |
5772 KB |
Output is correct |
14 |
Correct |
48 ms |
5772 KB |
Output is correct |
15 |
Correct |
13 ms |
5772 KB |
Output is correct |