# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
12204 |
2014-12-24T08:15:54 Z |
qja0950 |
격자 보존하기 (GA9_preserve) |
C++ |
|
32 ms |
1876 KB |
//
// main.cpp
// 1. preserve
//
// Created by KJBS2 on 2014. 12. 24..
// Copyright (c) 2014년 KJBS2. All rights reserved.
//
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
#define MAX_K 101101
int N, K, D;
int Sort[MAX_K];
int Sum[MAX_K];
int first, second;
bool cmp(int a, int b) {
return a > b;
}
void INPUT() {
scanf("%d%d%d", &N, &K, &D);
int a; scanf("%d", &a); first = a-1;
for(int i=1; i<K; i++) {
int b; scanf("%d", &b);
Sort[i] = b-a-1;
a=b;
}
second = N - a;
sort(Sort+1, Sort+K, cmp);
}
int main() {
INPUT();
for(int i=1; i<K; i++) {
Sum[i] = Sum[i-1] + Sort[i];
}
int nowD = D/2;
if(nowD >= K) nowD = K-1;
int ans = Sum[nowD];
nowD = (D-1)/2; if(nowD >= K) nowD = K-1;
ans = max(ans, Sum[nowD] + first);
nowD = (D-1)/2; if(nowD >= K) nowD = K-1;
ans = max(ans, Sum[nowD] + second);
nowD = (D-2)/2; if(nowD >= K) nowD = K-1;
ans = max(ans, Sum[nowD] + first + second);
printf("%d", ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1876 KB |
Output is correct |
2 |
Correct |
0 ms |
1876 KB |
Output is correct |
3 |
Correct |
0 ms |
1876 KB |
Output is correct |
4 |
Correct |
0 ms |
1876 KB |
Output is correct |
5 |
Correct |
0 ms |
1876 KB |
Output is correct |
6 |
Correct |
0 ms |
1876 KB |
Output is correct |
7 |
Correct |
0 ms |
1876 KB |
Output is correct |
8 |
Correct |
0 ms |
1876 KB |
Output is correct |
9 |
Correct |
0 ms |
1876 KB |
Output is correct |
10 |
Correct |
0 ms |
1876 KB |
Output is correct |
11 |
Correct |
0 ms |
1876 KB |
Output is correct |
12 |
Correct |
0 ms |
1876 KB |
Output is correct |
13 |
Correct |
0 ms |
1876 KB |
Output is correct |
14 |
Correct |
0 ms |
1876 KB |
Output is correct |
15 |
Correct |
0 ms |
1876 KB |
Output is correct |
16 |
Correct |
0 ms |
1876 KB |
Output is correct |
17 |
Correct |
0 ms |
1876 KB |
Output is correct |
18 |
Correct |
0 ms |
1876 KB |
Output is correct |
19 |
Correct |
0 ms |
1876 KB |
Output is correct |
20 |
Correct |
0 ms |
1876 KB |
Output is correct |
21 |
Correct |
0 ms |
1876 KB |
Output is correct |
22 |
Correct |
0 ms |
1876 KB |
Output is correct |
23 |
Correct |
0 ms |
1876 KB |
Output is correct |
24 |
Correct |
0 ms |
1876 KB |
Output is correct |
25 |
Correct |
0 ms |
1876 KB |
Output is correct |
26 |
Correct |
0 ms |
1876 KB |
Output is correct |
27 |
Correct |
0 ms |
1876 KB |
Output is correct |
28 |
Correct |
0 ms |
1876 KB |
Output is correct |
29 |
Correct |
0 ms |
1876 KB |
Output is correct |
30 |
Correct |
0 ms |
1876 KB |
Output is correct |
31 |
Correct |
0 ms |
1876 KB |
Output is correct |
32 |
Correct |
0 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1876 KB |
Output is correct |
2 |
Correct |
0 ms |
1876 KB |
Output is correct |
3 |
Correct |
0 ms |
1876 KB |
Output is correct |
4 |
Correct |
0 ms |
1876 KB |
Output is correct |
5 |
Correct |
0 ms |
1876 KB |
Output is correct |
6 |
Correct |
0 ms |
1876 KB |
Output is correct |
7 |
Correct |
0 ms |
1876 KB |
Output is correct |
8 |
Correct |
0 ms |
1876 KB |
Output is correct |
9 |
Correct |
0 ms |
1876 KB |
Output is correct |
10 |
Correct |
0 ms |
1876 KB |
Output is correct |
11 |
Correct |
0 ms |
1876 KB |
Output is correct |
12 |
Correct |
0 ms |
1876 KB |
Output is correct |
13 |
Correct |
0 ms |
1876 KB |
Output is correct |
14 |
Correct |
0 ms |
1876 KB |
Output is correct |
15 |
Correct |
0 ms |
1876 KB |
Output is correct |
16 |
Correct |
0 ms |
1876 KB |
Output is correct |
17 |
Correct |
0 ms |
1876 KB |
Output is correct |
18 |
Correct |
0 ms |
1876 KB |
Output is correct |
19 |
Correct |
0 ms |
1876 KB |
Output is correct |
20 |
Correct |
0 ms |
1876 KB |
Output is correct |
21 |
Correct |
0 ms |
1876 KB |
Output is correct |
22 |
Correct |
0 ms |
1876 KB |
Output is correct |
23 |
Correct |
0 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1876 KB |
Output is correct |
2 |
Correct |
0 ms |
1876 KB |
Output is correct |
3 |
Correct |
0 ms |
1876 KB |
Output is correct |
4 |
Correct |
0 ms |
1876 KB |
Output is correct |
5 |
Correct |
0 ms |
1876 KB |
Output is correct |
6 |
Correct |
0 ms |
1876 KB |
Output is correct |
7 |
Correct |
0 ms |
1876 KB |
Output is correct |
8 |
Correct |
0 ms |
1876 KB |
Output is correct |
9 |
Correct |
0 ms |
1876 KB |
Output is correct |
10 |
Correct |
0 ms |
1876 KB |
Output is correct |
11 |
Correct |
0 ms |
1876 KB |
Output is correct |
12 |
Correct |
0 ms |
1876 KB |
Output is correct |
13 |
Correct |
0 ms |
1876 KB |
Output is correct |
14 |
Correct |
0 ms |
1876 KB |
Output is correct |
15 |
Correct |
0 ms |
1876 KB |
Output is correct |
16 |
Correct |
0 ms |
1876 KB |
Output is correct |
17 |
Correct |
0 ms |
1876 KB |
Output is correct |
18 |
Correct |
0 ms |
1876 KB |
Output is correct |
19 |
Correct |
0 ms |
1876 KB |
Output is correct |
20 |
Correct |
0 ms |
1876 KB |
Output is correct |
21 |
Correct |
0 ms |
1876 KB |
Output is correct |
22 |
Correct |
0 ms |
1876 KB |
Output is correct |
23 |
Correct |
0 ms |
1876 KB |
Output is correct |
24 |
Correct |
0 ms |
1876 KB |
Output is correct |
25 |
Correct |
0 ms |
1876 KB |
Output is correct |
26 |
Correct |
0 ms |
1876 KB |
Output is correct |
27 |
Correct |
0 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
1876 KB |
Output is correct |
2 |
Correct |
28 ms |
1876 KB |
Output is correct |
3 |
Correct |
24 ms |
1876 KB |
Output is correct |
4 |
Correct |
32 ms |
1876 KB |
Output is correct |
5 |
Correct |
32 ms |
1876 KB |
Output is correct |
6 |
Correct |
32 ms |
1876 KB |
Output is correct |
7 |
Correct |
32 ms |
1876 KB |
Output is correct |
8 |
Correct |
24 ms |
1876 KB |
Output is correct |
9 |
Correct |
12 ms |
1876 KB |
Output is correct |
10 |
Correct |
8 ms |
1876 KB |
Output is correct |
11 |
Correct |
32 ms |
1876 KB |
Output is correct |
12 |
Correct |
20 ms |
1876 KB |
Output is correct |
13 |
Correct |
24 ms |
1876 KB |
Output is correct |
14 |
Correct |
28 ms |
1876 KB |
Output is correct |
15 |
Correct |
32 ms |
1876 KB |
Output is correct |
16 |
Correct |
28 ms |
1876 KB |
Output is correct |
17 |
Correct |
24 ms |
1876 KB |
Output is correct |
18 |
Correct |
28 ms |
1876 KB |
Output is correct |
19 |
Correct |
28 ms |
1876 KB |
Output is correct |
20 |
Correct |
0 ms |
1876 KB |
Output is correct |
21 |
Correct |
0 ms |
1876 KB |
Output is correct |
22 |
Correct |
28 ms |
1876 KB |
Output is correct |
23 |
Correct |
32 ms |
1876 KB |
Output is correct |
24 |
Correct |
20 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1876 KB |
Output is correct |
2 |
Correct |
32 ms |
1876 KB |
Output is correct |
3 |
Correct |
32 ms |
1876 KB |
Output is correct |
4 |
Correct |
28 ms |
1876 KB |
Output is correct |
5 |
Correct |
32 ms |
1876 KB |
Output is correct |
6 |
Correct |
32 ms |
1876 KB |
Output is correct |
7 |
Correct |
32 ms |
1876 KB |
Output is correct |
8 |
Correct |
32 ms |
1876 KB |
Output is correct |
9 |
Correct |
16 ms |
1876 KB |
Output is correct |
10 |
Correct |
4 ms |
1876 KB |
Output is correct |
11 |
Correct |
16 ms |
1876 KB |
Output is correct |
12 |
Correct |
16 ms |
1876 KB |
Output is correct |
13 |
Correct |
20 ms |
1876 KB |
Output is correct |
14 |
Correct |
24 ms |
1876 KB |
Output is correct |
15 |
Correct |
12 ms |
1876 KB |
Output is correct |
16 |
Correct |
24 ms |
1876 KB |
Output is correct |
17 |
Correct |
24 ms |
1876 KB |
Output is correct |
18 |
Correct |
24 ms |
1876 KB |
Output is correct |
19 |
Correct |
20 ms |
1876 KB |
Output is correct |
20 |
Correct |
20 ms |
1876 KB |
Output is correct |