Submission #20132

# Submission time Handle Problem Language Result Execution time Memory
20132 2016-02-27T12:34:25 Z hongjun7 격자 보존하기 (GA9_preserve) C++14
100 / 100
71 ms 2892 KB
#include <iostream>
#include <algorithm>
using namespace std;
#define MAXK 100000
int n, k, d, p[MAXK + 1];
struct BLOCK {
	int cost, value;
} b[MAXK + 5]; int bn;
inline bool cmp(BLOCK b1, BLOCK b2) {
	if (b1.value != b2.value) return b1.value > b2.value;
	return b1.cost < b2.cost;
}
int res;
void solve(int sum, int D) {
	for (int i = 1; i <= bn; i++) {
		if (b[i].cost <= D) {
			D -= b[i].cost;
			sum += b[i].value;
		}
	}
	if (res < sum) res = sum;
}
int main() {
	cin >> n >> k >> d;
	for (int i = 1; i <= k; i++) cin >> p[i];
	for (int i = 2; i <= k; i++) b[++bn] = { 2, p[i] - p[i - 1] - 1 };
	sort(b + 1, b + bn + 1, cmp);
	solve(0, d);
	solve(p[1] - 1, d - 1);
	solve(n - p[k], d - 1);
	solve(p[1] - 1 + n - p[k], d - 2);
	cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2892 KB Output is correct
2 Correct 0 ms 2892 KB Output is correct
3 Correct 0 ms 2892 KB Output is correct
4 Correct 0 ms 2892 KB Output is correct
5 Correct 0 ms 2892 KB Output is correct
6 Correct 0 ms 2892 KB Output is correct
7 Correct 0 ms 2892 KB Output is correct
8 Correct 0 ms 2892 KB Output is correct
9 Correct 0 ms 2892 KB Output is correct
10 Correct 0 ms 2892 KB Output is correct
11 Correct 0 ms 2892 KB Output is correct
12 Correct 0 ms 2892 KB Output is correct
13 Correct 0 ms 2892 KB Output is correct
14 Correct 0 ms 2892 KB Output is correct
15 Correct 0 ms 2892 KB Output is correct
16 Correct 0 ms 2892 KB Output is correct
17 Correct 0 ms 2892 KB Output is correct
18 Correct 0 ms 2892 KB Output is correct
19 Correct 0 ms 2892 KB Output is correct
20 Correct 0 ms 2892 KB Output is correct
21 Correct 0 ms 2892 KB Output is correct
22 Correct 0 ms 2892 KB Output is correct
23 Correct 0 ms 2892 KB Output is correct
24 Correct 0 ms 2892 KB Output is correct
25 Correct 0 ms 2892 KB Output is correct
26 Correct 0 ms 2892 KB Output is correct
27 Correct 0 ms 2892 KB Output is correct
28 Correct 0 ms 2892 KB Output is correct
29 Correct 0 ms 2892 KB Output is correct
30 Correct 0 ms 2892 KB Output is correct
31 Correct 0 ms 2892 KB Output is correct
32 Correct 0 ms 2892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2892 KB Output is correct
2 Correct 0 ms 2892 KB Output is correct
3 Correct 0 ms 2892 KB Output is correct
4 Correct 0 ms 2892 KB Output is correct
5 Correct 0 ms 2892 KB Output is correct
6 Correct 0 ms 2892 KB Output is correct
7 Correct 0 ms 2892 KB Output is correct
8 Correct 0 ms 2892 KB Output is correct
9 Correct 0 ms 2892 KB Output is correct
10 Correct 0 ms 2892 KB Output is correct
11 Correct 0 ms 2892 KB Output is correct
12 Correct 0 ms 2892 KB Output is correct
13 Correct 0 ms 2892 KB Output is correct
14 Correct 0 ms 2892 KB Output is correct
15 Correct 0 ms 2892 KB Output is correct
16 Correct 0 ms 2892 KB Output is correct
17 Correct 0 ms 2892 KB Output is correct
18 Correct 0 ms 2892 KB Output is correct
19 Correct 0 ms 2892 KB Output is correct
20 Correct 0 ms 2892 KB Output is correct
21 Correct 0 ms 2892 KB Output is correct
22 Correct 0 ms 2892 KB Output is correct
23 Correct 0 ms 2892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2892 KB Output is correct
2 Correct 0 ms 2892 KB Output is correct
3 Correct 0 ms 2892 KB Output is correct
4 Correct 0 ms 2892 KB Output is correct
5 Correct 0 ms 2892 KB Output is correct
6 Correct 0 ms 2892 KB Output is correct
7 Correct 0 ms 2892 KB Output is correct
8 Correct 0 ms 2892 KB Output is correct
9 Correct 0 ms 2892 KB Output is correct
10 Correct 0 ms 2892 KB Output is correct
11 Correct 0 ms 2892 KB Output is correct
12 Correct 0 ms 2892 KB Output is correct
13 Correct 0 ms 2892 KB Output is correct
14 Correct 0 ms 2892 KB Output is correct
15 Correct 0 ms 2892 KB Output is correct
16 Correct 0 ms 2892 KB Output is correct
17 Correct 0 ms 2892 KB Output is correct
18 Correct 0 ms 2892 KB Output is correct
19 Correct 0 ms 2892 KB Output is correct
20 Correct 0 ms 2892 KB Output is correct
21 Correct 0 ms 2892 KB Output is correct
22 Correct 0 ms 2892 KB Output is correct
23 Correct 0 ms 2892 KB Output is correct
24 Correct 0 ms 2892 KB Output is correct
25 Correct 0 ms 2892 KB Output is correct
26 Correct 0 ms 2892 KB Output is correct
27 Correct 0 ms 2892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2892 KB Output is correct
2 Correct 66 ms 2892 KB Output is correct
3 Correct 71 ms 2892 KB Output is correct
4 Correct 59 ms 2892 KB Output is correct
5 Correct 52 ms 2892 KB Output is correct
6 Correct 63 ms 2892 KB Output is correct
7 Correct 61 ms 2892 KB Output is correct
8 Correct 63 ms 2892 KB Output is correct
9 Correct 34 ms 2892 KB Output is correct
10 Correct 21 ms 2892 KB Output is correct
11 Correct 67 ms 2892 KB Output is correct
12 Correct 63 ms 2892 KB Output is correct
13 Correct 68 ms 2892 KB Output is correct
14 Correct 68 ms 2892 KB Output is correct
15 Correct 69 ms 2892 KB Output is correct
16 Correct 34 ms 2892 KB Output is correct
17 Correct 57 ms 2892 KB Output is correct
18 Correct 39 ms 2892 KB Output is correct
19 Correct 69 ms 2892 KB Output is correct
20 Correct 0 ms 2892 KB Output is correct
21 Correct 0 ms 2892 KB Output is correct
22 Correct 61 ms 2892 KB Output is correct
23 Correct 64 ms 2892 KB Output is correct
24 Correct 59 ms 2892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 2892 KB Output is correct
2 Correct 66 ms 2892 KB Output is correct
3 Correct 48 ms 2892 KB Output is correct
4 Correct 59 ms 2892 KB Output is correct
5 Correct 64 ms 2892 KB Output is correct
6 Correct 62 ms 2892 KB Output is correct
7 Correct 69 ms 2892 KB Output is correct
8 Correct 66 ms 2892 KB Output is correct
9 Correct 34 ms 2892 KB Output is correct
10 Correct 20 ms 2892 KB Output is correct
11 Correct 51 ms 2892 KB Output is correct
12 Correct 37 ms 2892 KB Output is correct
13 Correct 53 ms 2892 KB Output is correct
14 Correct 38 ms 2892 KB Output is correct
15 Correct 50 ms 2892 KB Output is correct
16 Correct 45 ms 2892 KB Output is correct
17 Correct 60 ms 2892 KB Output is correct
18 Correct 53 ms 2892 KB Output is correct
19 Correct 52 ms 2892 KB Output is correct
20 Correct 39 ms 2892 KB Output is correct