Submission #12091

# Submission time Handle Problem Language Result Execution time Memory
12091 2014-12-21T04:23:53 Z kriii 격자 보존하기 (GA9_preserve) C++14
100 / 100
32 ms 3260 KB
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

vector<pair<int, int> > h;
int n,k,d;

int main()
{
	scanf ("%d %d %d",&n,&k,&d);
	int s = -1, e = -1;
	for (int i=0,p;i<k;i++){
		scanf ("%d",&p);
		if (e + 1 != p){
			if (e != -1) h.push_back(make_pair(s,e));
			s = e = p;
		}
		else e++;
	}
	h.push_back(make_pair(s,e));

	int u[3] = {0,max(h.front().first-1,n-h.back().second),h.front().first-1+n-h.back().second};

	vector<int> gap;
	for (int i=1;i<h.size();i++) gap.push_back(h[i].first - h[i-1].second - 1);
	gap.push_back(0);

	int sum = 0, bar = gap.size() * 2;
	for (int g : gap) sum += g;
	sort(gap.begin(),gap.end());
	
	int ans = 0;
	for (int g : gap){
		sum -= g; bar -= 2;
		for (int i=0;i<3;i++) if (bar + i <= d){
			if (ans < sum + u[i])
				ans = sum + u[i];
		}
	}

	printf ("%d\n",ans);

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