# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
92129 | 2019-01-01T15:30:29 Z | tjrwodnjs999 | 격자 보존하기 (GA9_preserve) | C++11 | 24 ms | 2112 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); if(k > 2 * n) k = 2 * n; 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])); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 1 ms | 376 KB | Output is correct |
3 | Correct | 1 ms | 376 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 1 ms | 376 KB | Output is correct |
7 | Correct | 1 ms | 376 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 1 ms | 376 KB | Output is correct |
17 | Correct | 1 ms | 376 KB | Output is correct |
18 | Correct | 1 ms | 376 KB | Output is correct |
19 | Correct | 1 ms | 376 KB | Output is correct |
20 | Correct | 1 ms | 376 KB | Output is correct |
21 | Correct | 1 ms | 252 KB | Output is correct |
22 | Correct | 1 ms | 376 KB | Output is correct |
23 | Correct | 1 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 1 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 376 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 1 ms | 376 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 252 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 376 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 376 KB | Output is correct |
14 | Correct | 1 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 376 KB | Output is correct |
16 | Correct | 1 ms | 256 KB | Output is correct |
17 | Correct | 1 ms | 252 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 1 ms | 256 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 1 ms | 376 KB | Output is correct |
22 | Correct | 1 ms | 376 KB | Output is correct |
23 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 376 KB | Output is correct |
9 | Correct | 1 ms | 376 KB | Output is correct |
10 | Correct | 1 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 380 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 1 ms | 376 KB | Output is correct |
15 | Correct | 1 ms | 376 KB | Output is correct |
16 | Correct | 1 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 380 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 1 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 1 ms | 256 KB | Output is correct |
24 | Correct | 1 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 1 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 1016 KB | Output is correct |
2 | Correct | 23 ms | 1056 KB | Output is correct |
3 | Correct | 23 ms | 1144 KB | Output is correct |
4 | Correct | 23 ms | 1144 KB | Output is correct |
5 | Correct | 24 ms | 1144 KB | Output is correct |
6 | Correct | 23 ms | 1144 KB | Output is correct |
7 | Correct | 23 ms | 1116 KB | Output is correct |
8 | Correct | 23 ms | 1016 KB | Output is correct |
9 | Correct | 12 ms | 632 KB | Output is correct |
10 | Correct | 8 ms | 504 KB | Output is correct |
11 | Correct | 23 ms | 1016 KB | Output is correct |
12 | Correct | 22 ms | 1016 KB | Output is correct |
13 | Correct | 22 ms | 1016 KB | Output is correct |
14 | Correct | 21 ms | 1116 KB | Output is correct |
15 | Correct | 23 ms | 1016 KB | Output is correct |
16 | Correct | 23 ms | 1144 KB | Output is correct |
17 | Correct | 22 ms | 1020 KB | Output is correct |
18 | Correct | 22 ms | 1144 KB | Output is correct |
19 | Correct | 22 ms | 1016 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 256 KB | Output is correct |
22 | Correct | 21 ms | 1016 KB | Output is correct |
23 | Correct | 23 ms | 1144 KB | Output is correct |
24 | Correct | 21 ms | 1016 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 1124 KB | Output is correct |
2 | Correct | 23 ms | 2052 KB | Output is correct |
3 | Correct | 24 ms | 2048 KB | Output is correct |
4 | Correct | 24 ms | 2040 KB | Output is correct |
5 | Correct | 23 ms | 2112 KB | Output is correct |
6 | Correct | 24 ms | 2040 KB | Output is correct |
7 | Correct | 24 ms | 2040 KB | Output is correct |
8 | Correct | 24 ms | 2040 KB | Output is correct |
9 | Correct | 13 ms | 1272 KB | Output is correct |
10 | Correct | 8 ms | 888 KB | Output is correct |
11 | Correct | 16 ms | 1532 KB | Output is correct |
12 | Correct | 19 ms | 1656 KB | Output is correct |
13 | Correct | 19 ms | 1656 KB | Output is correct |
14 | Correct | 18 ms | 1656 KB | Output is correct |
15 | Correct | 16 ms | 1528 KB | Output is correct |
16 | Correct | 19 ms | 1772 KB | Output is correct |
17 | Correct | 21 ms | 1912 KB | Output is correct |
18 | Correct | 18 ms | 1784 KB | Output is correct |
19 | Correct | 18 ms | 1656 KB | Output is correct |
20 | Correct | 20 ms | 1784 KB | Output is correct |