Submission #12155

# Submission time Handle Problem Language Result Execution time Memory
12155 2014-12-21T12:05:53 Z xhae 격자 보존하기 (GA9_preserve) C++14
91 / 100
28 ms 1868 KB
#include <cstdio>
#include <algorithm>

using namespace std;

int n, K, data[100000], cand[99999], d;

int main(void)
{
	scanf("%d %d %d", &n, &K, &d);
	int start, end;
	for(int i = 0; i < K; i++) 
	{
		scanf("%d", data + i);
		if(i == 0) start = data[0] - 1;
		else if(i == K - 1) end = n - data[i];
		if(i > 0) cand[i - 1] = data[i] - data[i - 1] - 1;
	}

	sort(cand, cand + K - 1);
	int ans = 0;
	int cur = 0;
	for(int i = 0; i < K - 1; i++)
	{
		if((i + 1) * 2 > d) break;
		int ind = K - 2 - i;
		cur += cand[ind];				
	}

	ans = cur;
	
	if(d >= 1)
	{
		cur = max(start, end);
		for(int i = 0; i < K - 1; i++)
		{
			if((i + 1) * 2 > d - 1) break;
			int ind = K - 2 - i;
			cur += cand[ind];				
		}
		ans = max(ans, cur);
	}

	if(d >= 2)
	{
		cur = start + end;
		for(int i = 0; i < K - 1; i++)
		{
			if((i + 1) * 2 > d - 2) break;
			int ind = K - 2 - i;
			cur += cand[ind];				
		}
		ans = max(ans, cur);
	}

	printf("%d\n", ans);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1868 KB Output is correct
2 Incorrect 0 ms 1868 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1868 KB Output is correct
2 Correct 0 ms 1868 KB Output is correct
3 Correct 0 ms 1868 KB Output is correct
4 Correct 0 ms 1868 KB Output is correct
5 Correct 0 ms 1868 KB Output is correct
6 Correct 0 ms 1868 KB Output is correct
7 Correct 0 ms 1868 KB Output is correct
8 Correct 0 ms 1868 KB Output is correct
9 Correct 0 ms 1868 KB Output is correct
10 Correct 0 ms 1868 KB Output is correct
11 Correct 0 ms 1868 KB Output is correct
12 Correct 0 ms 1868 KB Output is correct
13 Correct 0 ms 1868 KB Output is correct
14 Correct 0 ms 1868 KB Output is correct
15 Correct 0 ms 1868 KB Output is correct
16 Correct 0 ms 1868 KB Output is correct
17 Correct 0 ms 1868 KB Output is correct
18 Correct 0 ms 1868 KB Output is correct
19 Correct 0 ms 1868 KB Output is correct
20 Correct 0 ms 1868 KB Output is correct
21 Correct 0 ms 1868 KB Output is correct
22 Correct 0 ms 1868 KB Output is correct
23 Correct 0 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1868 KB Output is correct
2 Correct 0 ms 1868 KB Output is correct
3 Correct 0 ms 1868 KB Output is correct
4 Correct 0 ms 1868 KB Output is correct
5 Correct 0 ms 1868 KB Output is correct
6 Correct 0 ms 1868 KB Output is correct
7 Correct 0 ms 1868 KB Output is correct
8 Correct 0 ms 1868 KB Output is correct
9 Correct 0 ms 1868 KB Output is correct
10 Correct 0 ms 1868 KB Output is correct
11 Correct 0 ms 1868 KB Output is correct
12 Correct 0 ms 1868 KB Output is correct
13 Correct 0 ms 1868 KB Output is correct
14 Correct 0 ms 1868 KB Output is correct
15 Correct 0 ms 1868 KB Output is correct
16 Correct 0 ms 1868 KB Output is correct
17 Correct 0 ms 1868 KB Output is correct
18 Correct 0 ms 1868 KB Output is correct
19 Correct 0 ms 1868 KB Output is correct
20 Correct 0 ms 1868 KB Output is correct
21 Correct 0 ms 1868 KB Output is correct
22 Correct 0 ms 1868 KB Output is correct
23 Correct 0 ms 1868 KB Output is correct
24 Correct 0 ms 1868 KB Output is correct
25 Correct 0 ms 1868 KB Output is correct
26 Correct 0 ms 1868 KB Output is correct
27 Correct 0 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1868 KB Output is correct
2 Correct 20 ms 1868 KB Output is correct
3 Correct 24 ms 1868 KB Output is correct
4 Correct 28 ms 1868 KB Output is correct
5 Correct 24 ms 1868 KB Output is correct
6 Correct 24 ms 1868 KB Output is correct
7 Correct 20 ms 1868 KB Output is correct
8 Correct 20 ms 1868 KB Output is correct
9 Correct 8 ms 1868 KB Output is correct
10 Correct 8 ms 1868 KB Output is correct
11 Correct 24 ms 1868 KB Output is correct
12 Correct 24 ms 1868 KB Output is correct
13 Correct 24 ms 1868 KB Output is correct
14 Correct 28 ms 1868 KB Output is correct
15 Correct 28 ms 1868 KB Output is correct
16 Correct 28 ms 1868 KB Output is correct
17 Correct 20 ms 1868 KB Output is correct
18 Correct 16 ms 1868 KB Output is correct
19 Correct 24 ms 1868 KB Output is correct
20 Correct 0 ms 1868 KB Output is correct
21 Correct 0 ms 1868 KB Output is correct
22 Correct 24 ms 1868 KB Output is correct
23 Correct 24 ms 1868 KB Output is correct
24 Correct 16 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1868 KB Output is correct
2 Correct 24 ms 1868 KB Output is correct
3 Correct 28 ms 1868 KB Output is correct
4 Correct 20 ms 1868 KB Output is correct
5 Correct 28 ms 1868 KB Output is correct
6 Correct 20 ms 1868 KB Output is correct
7 Correct 28 ms 1868 KB Output is correct
8 Correct 24 ms 1868 KB Output is correct
9 Correct 4 ms 1868 KB Output is correct
10 Correct 8 ms 1868 KB Output is correct
11 Correct 16 ms 1868 KB Output is correct
12 Correct 16 ms 1868 KB Output is correct
13 Correct 16 ms 1868 KB Output is correct
14 Correct 20 ms 1868 KB Output is correct
15 Correct 20 ms 1868 KB Output is correct
16 Correct 16 ms 1868 KB Output is correct
17 Correct 24 ms 1868 KB Output is correct
18 Correct 20 ms 1868 KB Output is correct
19 Correct 20 ms 1868 KB Output is correct
20 Correct 24 ms 1868 KB Output is correct