Submission #20147

# Submission time Handle Problem Language Result Execution time Memory
20147 2016-02-28T10:20:05 Z kdh9949 격자 보존하기 (GA9_preserve) C++
56 / 100
37 ms 1864 KB
#include <cstdio>
#include <algorithm>
using namespace std;

int l, n, k, a[100010], s[100010];

int main(){
    scanf("%d%d%d", &l, &n, &k);
    for(int i = 0; i < n; i++) scanf("%d", a + i);
    sort(a, a + n);
    for(int i = 1; i < n; i++) s[i] = a[i] - a[i - 1] - 1;
    sort(s + 1, s + n);
    reverse(s + 1, s + n);
    for(int i = 1; i < n; i++) s[i] += s[i - 1];
    if(k == 1) printf("%d", max(a[0] - 1, l - a[n - 1]));
    else if(k % 2) printf("%d", max(s[k / 2] + max(a[0] - 1, l - a[n - 1]), s[k / 2 - 1] + a[0] - 1 + l - a[n - 1]));
    else printf("%d", max(s[k / 2], s[k / 2 - 1] + a[0] - 1 + l - a[n - 1]));
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
4 Correct 0 ms 1864 KB Output is correct
5 Correct 0 ms 1864 KB Output is correct
6 Correct 0 ms 1864 KB Output is correct
7 Correct 0 ms 1864 KB Output is correct
8 Incorrect 0 ms 1864 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
4 Correct 0 ms 1864 KB Output is correct
5 Correct 0 ms 1864 KB Output is correct
6 Correct 0 ms 1864 KB Output is correct
7 Correct 0 ms 1864 KB Output is correct
8 Correct 0 ms 1864 KB Output is correct
9 Correct 0 ms 1864 KB Output is correct
10 Correct 0 ms 1864 KB Output is correct
11 Correct 0 ms 1864 KB Output is correct
12 Correct 0 ms 1864 KB Output is correct
13 Correct 0 ms 1864 KB Output is correct
14 Correct 0 ms 1864 KB Output is correct
15 Correct 0 ms 1864 KB Output is correct
16 Correct 0 ms 1864 KB Output is correct
17 Correct 0 ms 1864 KB Output is correct
18 Correct 0 ms 1864 KB Output is correct
19 Correct 0 ms 1864 KB Output is correct
20 Correct 0 ms 1864 KB Output is correct
21 Correct 0 ms 1864 KB Output is correct
22 Correct 0 ms 1864 KB Output is correct
23 Correct 0 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
4 Correct 0 ms 1864 KB Output is correct
5 Correct 0 ms 1864 KB Output is correct
6 Correct 0 ms 1864 KB Output is correct
7 Correct 0 ms 1864 KB Output is correct
8 Correct 0 ms 1864 KB Output is correct
9 Correct 0 ms 1864 KB Output is correct
10 Correct 0 ms 1864 KB Output is correct
11 Correct 0 ms 1864 KB Output is correct
12 Correct 0 ms 1864 KB Output is correct
13 Correct 0 ms 1864 KB Output is correct
14 Correct 0 ms 1864 KB Output is correct
15 Correct 0 ms 1864 KB Output is correct
16 Correct 0 ms 1864 KB Output is correct
17 Correct 0 ms 1864 KB Output is correct
18 Correct 0 ms 1864 KB Output is correct
19 Correct 0 ms 1864 KB Output is correct
20 Correct 0 ms 1864 KB Output is correct
21 Correct 0 ms 1864 KB Output is correct
22 Correct 0 ms 1864 KB Output is correct
23 Correct 0 ms 1864 KB Output is correct
24 Correct 0 ms 1864 KB Output is correct
25 Correct 0 ms 1864 KB Output is correct
26 Correct 0 ms 1864 KB Output is correct
27 Correct 0 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1864 KB Output is correct
2 Correct 31 ms 1864 KB Output is correct
3 Correct 37 ms 1864 KB Output is correct
4 Correct 36 ms 1864 KB Output is correct
5 Correct 35 ms 1864 KB Output is correct
6 Correct 30 ms 1864 KB Output is correct
7 Correct 36 ms 1864 KB Output is correct
8 Correct 25 ms 1864 KB Output is correct
9 Correct 15 ms 1864 KB Output is correct
10 Correct 0 ms 1864 KB Output is correct
11 Correct 26 ms 1864 KB Output is correct
12 Correct 21 ms 1864 KB Output is correct
13 Correct 35 ms 1864 KB Output is correct
14 Correct 26 ms 1864 KB Output is correct
15 Correct 30 ms 1864 KB Output is correct
16 Correct 29 ms 1864 KB Output is correct
17 Correct 33 ms 1864 KB Output is correct
18 Correct 24 ms 1864 KB Output is correct
19 Correct 33 ms 1864 KB Output is correct
20 Correct 0 ms 1864 KB Output is correct
21 Correct 0 ms 1864 KB Output is correct
22 Correct 20 ms 1864 KB Output is correct
23 Correct 35 ms 1864 KB Output is correct
24 Correct 23 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 1860 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -