Submission #12134

# Submission time Handle Problem Language Result Execution time Memory
12134 2014-12-21T08:07:31 Z gs14004 격자 보존하기 (GA9_preserve) C++
100 / 100
32 ms 1868 KB
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int seg[100005];
int lseg, rseg, a[100005];

int main(){
    int l,n,d;
    scanf("%d %d %d",&l,&n,&d);
    for (int i=0; i<n; i++) {
        scanf("%d",&a[i]);
        if(i == 0) lseg = a[i] - 1;
        if(i == n-1) rseg = l - a[i];
        if(i) seg[i-1] = (a[i] - a[i-1] - 1);
    }
    sort(seg,seg+n-1);
    reverse(seg,seg+n-1);
    int ans1 = 0;
    for (int i=0; i<n-1 && i<d/2; i++) {
        ans1 += seg[i];
    }
    int ans2 = max(lseg,rseg);
    for (int i=0; i<n-1 && i<(d-1)/2; i++) {
        ans2 += seg[i];
    }
    int ans3 = lseg + rseg;
    for (int i=0; i<n-1 && i<(d-2)/2; i++) {
        ans3 += seg[i];
    }
    if(d == 1) printf("%d",max(ans1,ans2));
    else printf("%d",max(ans1,max(ans2,ans3)));
}
# 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 20 ms 1868 KB Output is correct
2 Correct 24 ms 1868 KB Output is correct
3 Correct 28 ms 1868 KB Output is correct
4 Correct 20 ms 1868 KB Output is correct
5 Correct 32 ms 1868 KB Output is correct
6 Correct 28 ms 1868 KB Output is correct
7 Correct 28 ms 1868 KB Output is correct
8 Correct 20 ms 1868 KB Output is correct
9 Correct 16 ms 1868 KB Output is correct
10 Correct 8 ms 1868 KB Output is correct
11 Correct 20 ms 1868 KB Output is correct
12 Correct 16 ms 1868 KB Output is correct
13 Correct 24 ms 1868 KB Output is correct
14 Correct 24 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 28 ms 1868 KB Output is correct
18 Correct 20 ms 1868 KB Output is correct
19 Correct 24 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 24 ms 1868 KB Output is correct
23 Correct 20 ms 1868 KB Output is correct
24 Correct 20 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 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 32 ms 1868 KB Output is correct
5 Correct 16 ms 1868 KB Output is correct
6 Correct 20 ms 1868 KB Output is correct
7 Correct 24 ms 1868 KB Output is correct
8 Correct 28 ms 1868 KB Output is correct
9 Correct 8 ms 1868 KB Output is correct
10 Correct 8 ms 1868 KB Output is correct
11 Correct 16 ms 1868 KB Output is correct
12 Correct 24 ms 1868 KB Output is correct
13 Correct 24 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 24 ms 1868 KB Output is correct
17 Correct 20 ms 1868 KB Output is correct
18 Correct 8 ms 1868 KB Output is correct
19 Correct 24 ms 1868 KB Output is correct
20 Correct 16 ms 1868 KB Output is correct