#include<stdio.h>
#include<algorithm>
int p[100001];
int dat[100010];
int main()
{
int n, d, k, i, j, c = -1, t, a=0;
scanf("%d%d%d", &n, &k, &d);
for(i=1; i<=k; i++)scanf("%d", p+i);
for(i=1; i<=k; i+=j)
{
dat[++c] = p[i] - p[i-1] - 1;
for(j=0; i+j<=k && p[i]+j == p[i+j]; j++);
}
dat[++c] = n-p[k];
std::sort(dat+1, dat+c);
a=0;
for(i=1; i*2<=d && i<c; i++) a += dat[c-i];
if(d>=1)
{
t=dat[0] > dat[c] ? dat[0]:dat[c];
for(i=1; i*2+1<=d && i<c; i++) t += dat[c-i];
if(t>a) a = t;
}
if(d>=2)
{
t=dat[0] + dat[c];
for(i=1; i*2+2<=d && i<c; i++) t += dat[c-i];
if(t>a) a = t;
}
printf("%d\n", a);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1868 KB |
Output is correct |
2 |
Correct |
0 ms |
1868 KB |
Output is correct |
3 |
Correct |
0 ms |
1868 KB |
Output is correct |
4 |
Correct |
0 ms |
1868 KB |
Output is correct |
5 |
Correct |
0 ms |
1868 KB |
Output is correct |
6 |
Correct |
0 ms |
1868 KB |
Output is correct |
7 |
Correct |
0 ms |
1868 KB |
Output is correct |
8 |
Correct |
0 ms |
1868 KB |
Output is correct |
9 |
Correct |
0 ms |
1868 KB |
Output is correct |
10 |
Correct |
0 ms |
1868 KB |
Output is correct |
11 |
Correct |
0 ms |
1868 KB |
Output is correct |
12 |
Correct |
0 ms |
1868 KB |
Output is correct |
13 |
Correct |
0 ms |
1868 KB |
Output is correct |
14 |
Correct |
0 ms |
1868 KB |
Output is correct |
15 |
Correct |
0 ms |
1868 KB |
Output is correct |
16 |
Correct |
0 ms |
1868 KB |
Output is correct |
17 |
Correct |
0 ms |
1868 KB |
Output is correct |
18 |
Correct |
0 ms |
1868 KB |
Output is correct |
19 |
Correct |
0 ms |
1868 KB |
Output is correct |
20 |
Correct |
0 ms |
1868 KB |
Output is correct |
21 |
Correct |
0 ms |
1868 KB |
Output is correct |
22 |
Correct |
0 ms |
1868 KB |
Output is correct |
23 |
Correct |
0 ms |
1868 KB |
Output is correct |
24 |
Correct |
0 ms |
1868 KB |
Output is correct |
25 |
Correct |
0 ms |
1868 KB |
Output is correct |
26 |
Correct |
0 ms |
1868 KB |
Output is correct |
27 |
Correct |
0 ms |
1868 KB |
Output is correct |
28 |
Correct |
0 ms |
1868 KB |
Output is correct |
29 |
Correct |
0 ms |
1868 KB |
Output is correct |
30 |
Correct |
0 ms |
1868 KB |
Output is correct |
31 |
Correct |
0 ms |
1868 KB |
Output is correct |
32 |
Correct |
0 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1868 KB |
Output is correct |
2 |
Correct |
0 ms |
1868 KB |
Output is correct |
3 |
Correct |
0 ms |
1868 KB |
Output is correct |
4 |
Correct |
0 ms |
1868 KB |
Output is correct |
5 |
Correct |
0 ms |
1868 KB |
Output is correct |
6 |
Correct |
0 ms |
1868 KB |
Output is correct |
7 |
Correct |
0 ms |
1868 KB |
Output is correct |
8 |
Correct |
0 ms |
1868 KB |
Output is correct |
9 |
Correct |
0 ms |
1868 KB |
Output is correct |
10 |
Correct |
0 ms |
1868 KB |
Output is correct |
11 |
Correct |
0 ms |
1868 KB |
Output is correct |
12 |
Correct |
0 ms |
1868 KB |
Output is correct |
13 |
Correct |
0 ms |
1868 KB |
Output is correct |
14 |
Correct |
0 ms |
1868 KB |
Output is correct |
15 |
Correct |
0 ms |
1868 KB |
Output is correct |
16 |
Correct |
0 ms |
1868 KB |
Output is correct |
17 |
Correct |
0 ms |
1868 KB |
Output is correct |
18 |
Correct |
0 ms |
1868 KB |
Output is correct |
19 |
Correct |
0 ms |
1868 KB |
Output is correct |
20 |
Correct |
0 ms |
1868 KB |
Output is correct |
21 |
Correct |
0 ms |
1868 KB |
Output is correct |
22 |
Correct |
0 ms |
1868 KB |
Output is correct |
23 |
Correct |
0 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1868 KB |
Output is correct |
2 |
Correct |
0 ms |
1868 KB |
Output is correct |
3 |
Correct |
0 ms |
1868 KB |
Output is correct |
4 |
Correct |
0 ms |
1868 KB |
Output is correct |
5 |
Correct |
0 ms |
1868 KB |
Output is correct |
6 |
Correct |
0 ms |
1868 KB |
Output is correct |
7 |
Correct |
0 ms |
1868 KB |
Output is correct |
8 |
Correct |
0 ms |
1868 KB |
Output is correct |
9 |
Correct |
0 ms |
1868 KB |
Output is correct |
10 |
Correct |
0 ms |
1868 KB |
Output is correct |
11 |
Correct |
0 ms |
1868 KB |
Output is correct |
12 |
Correct |
0 ms |
1868 KB |
Output is correct |
13 |
Correct |
0 ms |
1868 KB |
Output is correct |
14 |
Correct |
0 ms |
1868 KB |
Output is correct |
15 |
Correct |
0 ms |
1868 KB |
Output is correct |
16 |
Correct |
0 ms |
1868 KB |
Output is correct |
17 |
Correct |
0 ms |
1868 KB |
Output is correct |
18 |
Correct |
0 ms |
1868 KB |
Output is correct |
19 |
Correct |
0 ms |
1868 KB |
Output is correct |
20 |
Correct |
0 ms |
1868 KB |
Output is correct |
21 |
Correct |
0 ms |
1868 KB |
Output is correct |
22 |
Correct |
0 ms |
1868 KB |
Output is correct |
23 |
Correct |
0 ms |
1868 KB |
Output is correct |
24 |
Correct |
0 ms |
1868 KB |
Output is correct |
25 |
Correct |
0 ms |
1868 KB |
Output is correct |
26 |
Correct |
0 ms |
1868 KB |
Output is correct |
27 |
Correct |
0 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1868 KB |
Output is correct |
2 |
Correct |
20 ms |
1868 KB |
Output is correct |
3 |
Correct |
24 ms |
1868 KB |
Output is correct |
4 |
Correct |
12 ms |
1868 KB |
Output is correct |
5 |
Correct |
28 ms |
1868 KB |
Output is correct |
6 |
Correct |
24 ms |
1868 KB |
Output is correct |
7 |
Correct |
20 ms |
1868 KB |
Output is correct |
8 |
Correct |
16 ms |
1868 KB |
Output is correct |
9 |
Correct |
12 ms |
1868 KB |
Output is correct |
10 |
Correct |
8 ms |
1868 KB |
Output is correct |
11 |
Correct |
12 ms |
1868 KB |
Output is correct |
12 |
Correct |
24 ms |
1868 KB |
Output is correct |
13 |
Correct |
20 ms |
1868 KB |
Output is correct |
14 |
Correct |
12 ms |
1868 KB |
Output is correct |
15 |
Correct |
20 ms |
1868 KB |
Output is correct |
16 |
Correct |
24 ms |
1868 KB |
Output is correct |
17 |
Correct |
16 ms |
1868 KB |
Output is correct |
18 |
Correct |
28 ms |
1868 KB |
Output is correct |
19 |
Correct |
20 ms |
1868 KB |
Output is correct |
20 |
Correct |
0 ms |
1868 KB |
Output is correct |
21 |
Correct |
0 ms |
1868 KB |
Output is correct |
22 |
Correct |
16 ms |
1868 KB |
Output is correct |
23 |
Correct |
24 ms |
1868 KB |
Output is correct |
24 |
Correct |
20 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1868 KB |
Output is correct |
2 |
Correct |
24 ms |
1868 KB |
Output is correct |
3 |
Correct |
20 ms |
1868 KB |
Output is correct |
4 |
Correct |
24 ms |
1868 KB |
Output is correct |
5 |
Correct |
20 ms |
1868 KB |
Output is correct |
6 |
Correct |
28 ms |
1868 KB |
Output is correct |
7 |
Correct |
20 ms |
1868 KB |
Output is correct |
8 |
Correct |
24 ms |
1868 KB |
Output is correct |
9 |
Correct |
12 ms |
1868 KB |
Output is correct |
10 |
Correct |
8 ms |
1868 KB |
Output is correct |
11 |
Correct |
8 ms |
1868 KB |
Output is correct |
12 |
Correct |
16 ms |
1868 KB |
Output is correct |
13 |
Correct |
16 ms |
1868 KB |
Output is correct |
14 |
Correct |
20 ms |
1868 KB |
Output is correct |
15 |
Correct |
20 ms |
1868 KB |
Output is correct |
16 |
Correct |
12 ms |
1868 KB |
Output is correct |
17 |
Correct |
24 ms |
1868 KB |
Output is correct |
18 |
Correct |
20 ms |
1868 KB |
Output is correct |
19 |
Correct |
20 ms |
1868 KB |
Output is correct |
20 |
Correct |
24 ms |
1868 KB |
Output is correct |