Submission #12772

# Submission time Handle Problem Language Result Execution time Memory
12772 2015-01-03T11:57:01 Z Qwaz 격자 보존하기 (GA9_preserve) C++
100 / 100
32 ms 2372 KB
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX = 100020;

int n, d, k, data[MAX];

void input(){
	scanf("%d%d%d", &n, &k, &d);

	for(int i = 0; i < k; i++)
		scanf("%d", &data[i]);
}

vector < int > gap;

int res;

void solve(){
	int front = data[0]-1, rear = n-data[k-1];

	for(int i = 1; i < k; i++)
		gap.push_back(data[i]-data[i-1]-1);

	sort(gap.begin(), gap.end());

	if(d >= 1){
		res = max(res, front);
		res = max(res, rear);
	}

	if(d >= 2)
		res = max(res, front+rear);

	int index = k-2, current = 0;
	while(index >= 0 && d >= 2){
		d -= 2;
		current += gap[index--];

		res = max(res, current);

		if(d >= 1){
			res = max(res, current+front);
			res = max(res, current+rear);
		}

		if(d >= 2)
			res = max(res, current+front+rear);
	}

	printf("%d\n", res);
}

int main(){
	input();

	solve();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1600 KB Output is correct
2 Correct 0 ms 1600 KB Output is correct
3 Correct 0 ms 1600 KB Output is correct
4 Correct 0 ms 1600 KB Output is correct
5 Correct 0 ms 1600 KB Output is correct
6 Correct 0 ms 1600 KB Output is correct
7 Correct 0 ms 1600 KB Output is correct
8 Correct 0 ms 1600 KB Output is correct
9 Correct 0 ms 1600 KB Output is correct
10 Correct 0 ms 1600 KB Output is correct
11 Correct 0 ms 1600 KB Output is correct
12 Correct 0 ms 1600 KB Output is correct
13 Correct 0 ms 1600 KB Output is correct
14 Correct 0 ms 1600 KB Output is correct
15 Correct 0 ms 1600 KB Output is correct
16 Correct 0 ms 1600 KB Output is correct
17 Correct 0 ms 1600 KB Output is correct
18 Correct 0 ms 1600 KB Output is correct
19 Correct 0 ms 1600 KB Output is correct
20 Correct 0 ms 1600 KB Output is correct
21 Correct 0 ms 1600 KB Output is correct
22 Correct 0 ms 1600 KB Output is correct
23 Correct 0 ms 1600 KB Output is correct
24 Correct 0 ms 1600 KB Output is correct
25 Correct 0 ms 1600 KB Output is correct
26 Correct 0 ms 1600 KB Output is correct
27 Correct 0 ms 1600 KB Output is correct
28 Correct 0 ms 1600 KB Output is correct
29 Correct 0 ms 1600 KB Output is correct
30 Correct 0 ms 1600 KB Output is correct
31 Correct 0 ms 1600 KB Output is correct
32 Correct 0 ms 1600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1600 KB Output is correct
2 Correct 0 ms 1600 KB Output is correct
3 Correct 0 ms 1600 KB Output is correct
4 Correct 0 ms 1600 KB Output is correct
5 Correct 0 ms 1600 KB Output is correct
6 Correct 0 ms 1600 KB Output is correct
7 Correct 0 ms 1600 KB Output is correct
8 Correct 0 ms 1600 KB Output is correct
9 Correct 0 ms 1600 KB Output is correct
10 Correct 0 ms 1600 KB Output is correct
11 Correct 0 ms 1600 KB Output is correct
12 Correct 0 ms 1600 KB Output is correct
13 Correct 0 ms 1600 KB Output is correct
14 Correct 0 ms 1600 KB Output is correct
15 Correct 0 ms 1600 KB Output is correct
16 Correct 0 ms 1600 KB Output is correct
17 Correct 0 ms 1600 KB Output is correct
18 Correct 0 ms 1600 KB Output is correct
19 Correct 0 ms 1600 KB Output is correct
20 Correct 0 ms 1600 KB Output is correct
21 Correct 0 ms 1600 KB Output is correct
22 Correct 0 ms 1600 KB Output is correct
23 Correct 0 ms 1600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1600 KB Output is correct
2 Correct 0 ms 1600 KB Output is correct
3 Correct 0 ms 1600 KB Output is correct
4 Correct 0 ms 1600 KB Output is correct
5 Correct 0 ms 1600 KB Output is correct
6 Correct 0 ms 1600 KB Output is correct
7 Correct 0 ms 1600 KB Output is correct
8 Correct 0 ms 1600 KB Output is correct
9 Correct 0 ms 1600 KB Output is correct
10 Correct 0 ms 1600 KB Output is correct
11 Correct 0 ms 1600 KB Output is correct
12 Correct 0 ms 1600 KB Output is correct
13 Correct 0 ms 1600 KB Output is correct
14 Correct 0 ms 1600 KB Output is correct
15 Correct 0 ms 1600 KB Output is correct
16 Correct 0 ms 1600 KB Output is correct
17 Correct 0 ms 1600 KB Output is correct
18 Correct 0 ms 1600 KB Output is correct
19 Correct 0 ms 1600 KB Output is correct
20 Correct 0 ms 1600 KB Output is correct
21 Correct 0 ms 1600 KB Output is correct
22 Correct 0 ms 1600 KB Output is correct
23 Correct 0 ms 1600 KB Output is correct
24 Correct 0 ms 1600 KB Output is correct
25 Correct 0 ms 1600 KB Output is correct
26 Correct 0 ms 1600 KB Output is correct
27 Correct 0 ms 1600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2372 KB Output is correct
2 Correct 24 ms 2372 KB Output is correct
3 Correct 28 ms 2372 KB Output is correct
4 Correct 20 ms 2372 KB Output is correct
5 Correct 20 ms 2372 KB Output is correct
6 Correct 28 ms 2372 KB Output is correct
7 Correct 24 ms 2372 KB Output is correct
8 Correct 28 ms 2372 KB Output is correct
9 Correct 12 ms 1988 KB Output is correct
10 Correct 8 ms 1732 KB Output is correct
11 Correct 12 ms 2372 KB Output is correct
12 Correct 28 ms 2372 KB Output is correct
13 Correct 28 ms 2372 KB Output is correct
14 Correct 24 ms 2372 KB Output is correct
15 Correct 28 ms 2372 KB Output is correct
16 Correct 24 ms 2372 KB Output is correct
17 Correct 24 ms 2372 KB Output is correct
18 Correct 24 ms 2372 KB Output is correct
19 Correct 24 ms 2372 KB Output is correct
20 Correct 0 ms 1600 KB Output is correct
21 Correct 0 ms 1600 KB Output is correct
22 Correct 28 ms 2372 KB Output is correct
23 Correct 28 ms 2372 KB Output is correct
24 Correct 20 ms 2372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2372 KB Output is correct
2 Correct 28 ms 2372 KB Output is correct
3 Correct 24 ms 2372 KB Output is correct
4 Correct 20 ms 2372 KB Output is correct
5 Correct 28 ms 2372 KB Output is correct
6 Correct 32 ms 2372 KB Output is correct
7 Correct 20 ms 2372 KB Output is correct
8 Correct 20 ms 2372 KB Output is correct
9 Correct 16 ms 1988 KB Output is correct
10 Correct 8 ms 1732 KB Output is correct
11 Correct 16 ms 2372 KB Output is correct
12 Correct 16 ms 2372 KB Output is correct
13 Correct 20 ms 2372 KB Output is correct
14 Correct 16 ms 2372 KB Output is correct
15 Correct 12 ms 2372 KB Output is correct
16 Correct 24 ms 2372 KB Output is correct
17 Correct 20 ms 2372 KB Output is correct
18 Correct 16 ms 2372 KB Output is correct
19 Correct 20 ms 2372 KB Output is correct
20 Correct 20 ms 2372 KB Output is correct