# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
13146 |
2015-01-31T18:38:45 Z |
yourID |
격자 보존하기 (GA9_preserve) |
C++14 |
|
810 ms |
2376 KB |
#include <cstdio>
#include <queue>
using namespace std;
priority_queue<int, vector<int>, less<int> > put;
int horse[100000];
int main() {
int start, end, n, k, d;
int i;
scanf("%d %d %d", &n, &k, &d);
for (i=0; i<k; ++i) {
scanf("%d", &horse[i]);
}
start = horse[0] - 1;
end = n - horse[k - 1];
for (i=1; i<k; ++i) {
put.push(horse[i] - horse[i - 1] - 1);
}
if (d == 1) printf("%d\n", (start > end) ? start : end);
else if (d == 2) printf("%d\n", (start + end > put.top()) ? (start + end) : put.top());
else {
int nd = d - 2;
int now = 0, max = -1;
for (i=0; i<nd/2; ++i) {
now += put.top();
put.pop();
}
nd %= 2;
nd += 2;
if (nd == 3) {
max = put.top() + start;
if (max < put.top() + end) {
max = put.top() + end;
}
if (max < start + end) {
max = start + end;
}
} else if (nd == 2) {
max = start + end;
if (max < put.top()) {
max = put.top();
}
}
printf("%d\n", now + max);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1604 KB |
Output is correct |
2 |
Correct |
0 ms |
1604 KB |
Output is correct |
3 |
Correct |
0 ms |
1604 KB |
Output is correct |
4 |
Correct |
0 ms |
1604 KB |
Output is correct |
5 |
Correct |
0 ms |
1604 KB |
Output is correct |
6 |
Correct |
0 ms |
1604 KB |
Output is correct |
7 |
Correct |
0 ms |
1604 KB |
Output is correct |
8 |
Incorrect |
0 ms |
1604 KB |
Output isn't correct |
9 |
Correct |
0 ms |
1604 KB |
Output is correct |
10 |
Correct |
0 ms |
1604 KB |
Output is correct |
11 |
Correct |
0 ms |
1604 KB |
Output is correct |
12 |
Correct |
0 ms |
1604 KB |
Output is correct |
13 |
Correct |
0 ms |
1604 KB |
Output is correct |
14 |
Correct |
0 ms |
1604 KB |
Output is correct |
15 |
Correct |
0 ms |
1604 KB |
Output is correct |
16 |
Correct |
0 ms |
1604 KB |
Output is correct |
17 |
Correct |
0 ms |
1604 KB |
Output is correct |
18 |
Incorrect |
0 ms |
1604 KB |
Output isn't correct |
19 |
Incorrect |
0 ms |
1604 KB |
Output isn't correct |
20 |
Correct |
0 ms |
1604 KB |
Output is correct |
21 |
Correct |
0 ms |
1604 KB |
Output is correct |
22 |
Correct |
0 ms |
1604 KB |
Output is correct |
23 |
Correct |
0 ms |
1604 KB |
Output is correct |
24 |
Correct |
0 ms |
1604 KB |
Output is correct |
25 |
Correct |
0 ms |
1604 KB |
Output is correct |
26 |
Correct |
0 ms |
1604 KB |
Output is correct |
27 |
Correct |
0 ms |
1604 KB |
Output is correct |
28 |
Correct |
0 ms |
1604 KB |
Output is correct |
29 |
Correct |
0 ms |
1604 KB |
Output is correct |
30 |
Correct |
0 ms |
1604 KB |
Output is correct |
31 |
Correct |
0 ms |
1604 KB |
Output is correct |
32 |
Correct |
0 ms |
1604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1604 KB |
Output is correct |
2 |
Correct |
0 ms |
1604 KB |
Output is correct |
3 |
Correct |
0 ms |
1604 KB |
Output is correct |
4 |
Correct |
0 ms |
1604 KB |
Output is correct |
5 |
Correct |
0 ms |
1604 KB |
Output is correct |
6 |
Correct |
0 ms |
1604 KB |
Output is correct |
7 |
Correct |
0 ms |
1604 KB |
Output is correct |
8 |
Correct |
0 ms |
1604 KB |
Output is correct |
9 |
Correct |
0 ms |
1604 KB |
Output is correct |
10 |
Correct |
0 ms |
1604 KB |
Output is correct |
11 |
Correct |
0 ms |
1604 KB |
Output is correct |
12 |
Correct |
0 ms |
1604 KB |
Output is correct |
13 |
Correct |
0 ms |
1604 KB |
Output is correct |
14 |
Correct |
0 ms |
1604 KB |
Output is correct |
15 |
Correct |
0 ms |
1604 KB |
Output is correct |
16 |
Correct |
0 ms |
1604 KB |
Output is correct |
17 |
Correct |
0 ms |
1604 KB |
Output is correct |
18 |
Correct |
0 ms |
1604 KB |
Output is correct |
19 |
Correct |
0 ms |
1604 KB |
Output is correct |
20 |
Correct |
0 ms |
1604 KB |
Output is correct |
21 |
Correct |
0 ms |
1604 KB |
Output is correct |
22 |
Correct |
0 ms |
1604 KB |
Output is correct |
23 |
Correct |
0 ms |
1604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1604 KB |
Output is correct |
2 |
Correct |
0 ms |
1604 KB |
Output is correct |
3 |
Correct |
0 ms |
1604 KB |
Output is correct |
4 |
Correct |
0 ms |
1604 KB |
Output is correct |
5 |
Correct |
0 ms |
1604 KB |
Output is correct |
6 |
Correct |
0 ms |
1604 KB |
Output is correct |
7 |
Correct |
0 ms |
1604 KB |
Output is correct |
8 |
Correct |
0 ms |
1604 KB |
Output is correct |
9 |
Correct |
0 ms |
1604 KB |
Output is correct |
10 |
Correct |
0 ms |
1604 KB |
Output is correct |
11 |
Correct |
0 ms |
1604 KB |
Output is correct |
12 |
Correct |
0 ms |
1604 KB |
Output is correct |
13 |
Correct |
0 ms |
1604 KB |
Output is correct |
14 |
Correct |
0 ms |
1604 KB |
Output is correct |
15 |
Correct |
0 ms |
1604 KB |
Output is correct |
16 |
Correct |
0 ms |
1604 KB |
Output is correct |
17 |
Correct |
0 ms |
1604 KB |
Output is correct |
18 |
Correct |
0 ms |
1604 KB |
Output is correct |
19 |
Correct |
0 ms |
1604 KB |
Output is correct |
20 |
Correct |
0 ms |
1604 KB |
Output is correct |
21 |
Correct |
0 ms |
1604 KB |
Output is correct |
22 |
Correct |
0 ms |
1604 KB |
Output is correct |
23 |
Correct |
0 ms |
1604 KB |
Output is correct |
24 |
Correct |
0 ms |
1604 KB |
Output is correct |
25 |
Correct |
0 ms |
1604 KB |
Output is correct |
26 |
Correct |
0 ms |
1604 KB |
Output is correct |
27 |
Correct |
0 ms |
1604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
2376 KB |
Output is correct |
2 |
Correct |
21 ms |
2376 KB |
Output is correct |
3 |
Correct |
17 ms |
2376 KB |
Output is correct |
4 |
Correct |
21 ms |
2376 KB |
Output is correct |
5 |
Correct |
20 ms |
2376 KB |
Output is correct |
6 |
Correct |
12 ms |
2376 KB |
Output is correct |
7 |
Correct |
0 ms |
2376 KB |
Output is correct |
8 |
Correct |
16 ms |
2376 KB |
Output is correct |
9 |
Correct |
8 ms |
1992 KB |
Output is correct |
10 |
Correct |
6 ms |
1736 KB |
Output is correct |
11 |
Correct |
0 ms |
2376 KB |
Output is correct |
12 |
Correct |
13 ms |
2376 KB |
Output is correct |
13 |
Correct |
25 ms |
2376 KB |
Output is correct |
14 |
Correct |
20 ms |
2376 KB |
Output is correct |
15 |
Correct |
21 ms |
2376 KB |
Output is correct |
16 |
Correct |
11 ms |
2376 KB |
Output is correct |
17 |
Correct |
20 ms |
2376 KB |
Output is correct |
18 |
Correct |
11 ms |
2376 KB |
Output is correct |
19 |
Correct |
14 ms |
2376 KB |
Output is correct |
20 |
Correct |
0 ms |
1604 KB |
Output is correct |
21 |
Correct |
0 ms |
1604 KB |
Output is correct |
22 |
Correct |
25 ms |
2376 KB |
Output is correct |
23 |
Correct |
26 ms |
2376 KB |
Output is correct |
24 |
Correct |
18 ms |
2376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
810 ms |
2376 KB |
Output is correct |
2 |
Correct |
310 ms |
2376 KB |
Output is correct |
3 |
Correct |
29 ms |
2376 KB |
Output is correct |
4 |
Correct |
19 ms |
2376 KB |
Output is correct |
5 |
Correct |
25 ms |
2376 KB |
Output is correct |
6 |
Correct |
22 ms |
2376 KB |
Output is correct |
7 |
Correct |
19 ms |
2376 KB |
Output is correct |
8 |
Correct |
19 ms |
2376 KB |
Output is correct |
9 |
Correct |
11 ms |
1992 KB |
Output is correct |
10 |
Correct |
0 ms |
1736 KB |
Output is correct |
11 |
Correct |
17 ms |
2376 KB |
Output is correct |
12 |
Correct |
0 ms |
2376 KB |
Output is correct |
13 |
Correct |
19 ms |
2376 KB |
Output is correct |
14 |
Correct |
24 ms |
2376 KB |
Output is correct |
15 |
Correct |
18 ms |
2376 KB |
Output is correct |
16 |
Correct |
22 ms |
2376 KB |
Output is correct |
17 |
Correct |
35 ms |
2376 KB |
Output is correct |
18 |
Correct |
18 ms |
2376 KB |
Output is correct |
19 |
Correct |
15 ms |
2376 KB |
Output is correct |
20 |
Correct |
30 ms |
2376 KB |
Output is correct |