#include <stdio.h>
#include <algorithm>
using namespace std;
int N, K, D, P, A[100002], Cnt, Ans;
int main(void) {
int i, Prev=0, t1, t2;
scanf("%d %d %d",&N,&K,&D);
for(i=1 ; i<=K ; i++) {
scanf("%d",&P);
A[++Cnt]=P-Prev-1;
Prev=P;
}
A[++Cnt]=N-Prev;
sort(A+2,A+Cnt);
t1=t2=0;
for(i=Cnt-1 ; i>=2 ; i--) {
t2+=2;
if(t2>D)
break;
t1+=A[i];
}
if(Ans<t1)
Ans=t1;
t1=A[1];
t2=1;
for(i=Cnt-1 ; i>=2 ; i--) {
t2+=2;
if(t2>D)
break;
t1+=A[i];
}
if(Ans<t1)
Ans=t1;
t1=A[Cnt];
t2=1;
for(i=Cnt-1 ; i>=2 ; i--) {
t2+=2;
if(t2>D)
break;
t1+=A[i];
}
if(Ans<t1)
Ans=t1;
t1=A[1]+A[Cnt];
t2=2;
for(i=Cnt-1 ; i>=2 ; i--) {
t2+=2;
if(t2>D)
break;
t1+=A[i];
}
if(Ans<t1)
Ans=t1;
printf("%d",Ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1476 KB |
Output is correct |
2 |
Correct |
0 ms |
1476 KB |
Output is correct |
3 |
Correct |
0 ms |
1476 KB |
Output is correct |
4 |
Correct |
0 ms |
1476 KB |
Output is correct |
5 |
Correct |
0 ms |
1476 KB |
Output is correct |
6 |
Correct |
0 ms |
1476 KB |
Output is correct |
7 |
Correct |
0 ms |
1476 KB |
Output is correct |
8 |
Correct |
0 ms |
1476 KB |
Output is correct |
9 |
Correct |
0 ms |
1476 KB |
Output is correct |
10 |
Correct |
0 ms |
1476 KB |
Output is correct |
11 |
Correct |
0 ms |
1476 KB |
Output is correct |
12 |
Correct |
0 ms |
1476 KB |
Output is correct |
13 |
Correct |
0 ms |
1476 KB |
Output is correct |
14 |
Correct |
0 ms |
1476 KB |
Output is correct |
15 |
Correct |
0 ms |
1476 KB |
Output is correct |
16 |
Correct |
0 ms |
1476 KB |
Output is correct |
17 |
Correct |
0 ms |
1476 KB |
Output is correct |
18 |
Correct |
0 ms |
1476 KB |
Output is correct |
19 |
Correct |
0 ms |
1476 KB |
Output is correct |
20 |
Correct |
0 ms |
1476 KB |
Output is correct |
21 |
Correct |
0 ms |
1476 KB |
Output is correct |
22 |
Correct |
0 ms |
1476 KB |
Output is correct |
23 |
Correct |
0 ms |
1476 KB |
Output is correct |
24 |
Correct |
0 ms |
1476 KB |
Output is correct |
25 |
Correct |
0 ms |
1476 KB |
Output is correct |
26 |
Correct |
0 ms |
1476 KB |
Output is correct |
27 |
Correct |
0 ms |
1476 KB |
Output is correct |
28 |
Correct |
0 ms |
1476 KB |
Output is correct |
29 |
Correct |
0 ms |
1476 KB |
Output is correct |
30 |
Correct |
0 ms |
1476 KB |
Output is correct |
31 |
Correct |
0 ms |
1476 KB |
Output is correct |
32 |
Correct |
0 ms |
1476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1476 KB |
Output is correct |
2 |
Correct |
0 ms |
1476 KB |
Output is correct |
3 |
Correct |
0 ms |
1476 KB |
Output is correct |
4 |
Correct |
0 ms |
1476 KB |
Output is correct |
5 |
Correct |
0 ms |
1476 KB |
Output is correct |
6 |
Correct |
0 ms |
1476 KB |
Output is correct |
7 |
Correct |
0 ms |
1476 KB |
Output is correct |
8 |
Correct |
0 ms |
1476 KB |
Output is correct |
9 |
Correct |
0 ms |
1476 KB |
Output is correct |
10 |
Correct |
0 ms |
1476 KB |
Output is correct |
11 |
Correct |
0 ms |
1476 KB |
Output is correct |
12 |
Correct |
0 ms |
1476 KB |
Output is correct |
13 |
Correct |
0 ms |
1476 KB |
Output is correct |
14 |
Correct |
0 ms |
1476 KB |
Output is correct |
15 |
Correct |
0 ms |
1476 KB |
Output is correct |
16 |
Correct |
0 ms |
1476 KB |
Output is correct |
17 |
Correct |
0 ms |
1476 KB |
Output is correct |
18 |
Correct |
0 ms |
1476 KB |
Output is correct |
19 |
Correct |
0 ms |
1476 KB |
Output is correct |
20 |
Correct |
0 ms |
1476 KB |
Output is correct |
21 |
Correct |
0 ms |
1476 KB |
Output is correct |
22 |
Correct |
0 ms |
1476 KB |
Output is correct |
23 |
Correct |
0 ms |
1476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1476 KB |
Output is correct |
2 |
Correct |
0 ms |
1476 KB |
Output is correct |
3 |
Correct |
0 ms |
1476 KB |
Output is correct |
4 |
Correct |
0 ms |
1476 KB |
Output is correct |
5 |
Correct |
0 ms |
1476 KB |
Output is correct |
6 |
Correct |
0 ms |
1476 KB |
Output is correct |
7 |
Correct |
0 ms |
1476 KB |
Output is correct |
8 |
Correct |
0 ms |
1476 KB |
Output is correct |
9 |
Correct |
0 ms |
1476 KB |
Output is correct |
10 |
Correct |
0 ms |
1476 KB |
Output is correct |
11 |
Correct |
0 ms |
1476 KB |
Output is correct |
12 |
Correct |
0 ms |
1476 KB |
Output is correct |
13 |
Correct |
0 ms |
1476 KB |
Output is correct |
14 |
Correct |
0 ms |
1476 KB |
Output is correct |
15 |
Correct |
0 ms |
1476 KB |
Output is correct |
16 |
Correct |
0 ms |
1476 KB |
Output is correct |
17 |
Correct |
0 ms |
1476 KB |
Output is correct |
18 |
Correct |
0 ms |
1476 KB |
Output is correct |
19 |
Correct |
0 ms |
1476 KB |
Output is correct |
20 |
Correct |
0 ms |
1476 KB |
Output is correct |
21 |
Correct |
0 ms |
1476 KB |
Output is correct |
22 |
Correct |
0 ms |
1476 KB |
Output is correct |
23 |
Correct |
0 ms |
1476 KB |
Output is correct |
24 |
Correct |
0 ms |
1476 KB |
Output is correct |
25 |
Correct |
0 ms |
1476 KB |
Output is correct |
26 |
Correct |
0 ms |
1476 KB |
Output is correct |
27 |
Correct |
0 ms |
1476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1476 KB |
Output is correct |
2 |
Correct |
16 ms |
1476 KB |
Output is correct |
3 |
Correct |
28 ms |
1476 KB |
Output is correct |
4 |
Correct |
28 ms |
1476 KB |
Output is correct |
5 |
Correct |
20 ms |
1476 KB |
Output is correct |
6 |
Correct |
28 ms |
1476 KB |
Output is correct |
7 |
Correct |
28 ms |
1476 KB |
Output is correct |
8 |
Correct |
20 ms |
1476 KB |
Output is correct |
9 |
Correct |
16 ms |
1476 KB |
Output is correct |
10 |
Correct |
4 ms |
1476 KB |
Output is correct |
11 |
Correct |
20 ms |
1476 KB |
Output is correct |
12 |
Correct |
20 ms |
1476 KB |
Output is correct |
13 |
Correct |
20 ms |
1476 KB |
Output is correct |
14 |
Correct |
20 ms |
1476 KB |
Output is correct |
15 |
Correct |
20 ms |
1476 KB |
Output is correct |
16 |
Correct |
20 ms |
1476 KB |
Output is correct |
17 |
Correct |
16 ms |
1476 KB |
Output is correct |
18 |
Correct |
16 ms |
1476 KB |
Output is correct |
19 |
Correct |
24 ms |
1476 KB |
Output is correct |
20 |
Correct |
0 ms |
1476 KB |
Output is correct |
21 |
Correct |
0 ms |
1476 KB |
Output is correct |
22 |
Correct |
16 ms |
1476 KB |
Output is correct |
23 |
Correct |
20 ms |
1476 KB |
Output is correct |
24 |
Correct |
16 ms |
1476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1476 KB |
Output is correct |
2 |
Correct |
24 ms |
1476 KB |
Output is correct |
3 |
Correct |
28 ms |
1476 KB |
Output is correct |
4 |
Correct |
20 ms |
1476 KB |
Output is correct |
5 |
Correct |
20 ms |
1476 KB |
Output is correct |
6 |
Correct |
20 ms |
1476 KB |
Output is correct |
7 |
Correct |
24 ms |
1476 KB |
Output is correct |
8 |
Correct |
28 ms |
1476 KB |
Output is correct |
9 |
Correct |
12 ms |
1476 KB |
Output is correct |
10 |
Correct |
4 ms |
1476 KB |
Output is correct |
11 |
Correct |
16 ms |
1476 KB |
Output is correct |
12 |
Correct |
20 ms |
1476 KB |
Output is correct |
13 |
Correct |
16 ms |
1476 KB |
Output is correct |
14 |
Correct |
16 ms |
1476 KB |
Output is correct |
15 |
Correct |
20 ms |
1476 KB |
Output is correct |
16 |
Correct |
20 ms |
1476 KB |
Output is correct |
17 |
Correct |
16 ms |
1476 KB |
Output is correct |
18 |
Correct |
12 ms |
1476 KB |
Output is correct |
19 |
Correct |
12 ms |
1476 KB |
Output is correct |
20 |
Correct |
24 ms |
1476 KB |
Output is correct |