답안 #20130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20130 2016-02-27T12:27:39 Z hongjun7 격자 보존하기 (GA9_preserve) C++14
61 / 100
115 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 = 0, D = 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];
	bn = 0; b[++bn] = { 1, p[1] - 1 }; b[++bn] = { 1, n - p[k] };
	for (int i = 2; i <= k; i++) b[++bn] = { 2, p[i] - p[i - 1] - 1 };
	sort(b + 1, b + bn + 1, cmp); solve();
	bn = 0; b[++bn] = { 1, p[1] - 1 };
	for (int i = 2; i <= k; i++) b[++bn] = { 2, p[i] - p[i - 1] - 1 };
	sort(b + 1, b + bn + 1, cmp); solve();
	bn = 0; b[++bn] = { 1, n - p[k] };
	for (int i = 2; i <= k; i++) b[++bn] = { 2, p[i] - p[i - 1] - 1 };
	sort(b + 1, b + bn + 1, cmp); solve();
	bn = 0;
	for (int i = 2; i <= k; i++) b[++bn] = { 2, p[i] - p[i - 1] - 1 };
	sort(b + 1, b + bn + 1, cmp); solve();
	printf("%d", res);
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 Incorrect 0 ms 2892 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 2892 KB Output is correct
2 Correct 92 ms 2892 KB Output is correct
3 Correct 85 ms 2892 KB Output is correct
4 Correct 97 ms 2892 KB Output is correct
5 Correct 110 ms 2892 KB Output is correct
6 Correct 104 ms 2892 KB Output is correct
7 Correct 115 ms 2892 KB Output is correct
8 Correct 109 ms 2892 KB Output is correct
9 Incorrect 54 ms 2892 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 2892 KB Output is correct
2 Correct 105 ms 2892 KB Output is correct
3 Correct 88 ms 2892 KB Output is correct
4 Correct 108 ms 2892 KB Output is correct
5 Correct 94 ms 2892 KB Output is correct
6 Correct 98 ms 2892 KB Output is correct
7 Correct 113 ms 2892 KB Output is correct
8 Correct 96 ms 2892 KB Output is correct
9 Correct 55 ms 2892 KB Output is correct
10 Correct 25 ms 2892 KB Output is correct
11 Correct 72 ms 2892 KB Output is correct
12 Correct 67 ms 2892 KB Output is correct
13 Correct 85 ms 2892 KB Output is correct
14 Correct 81 ms 2892 KB Output is correct
15 Correct 79 ms 2892 KB Output is correct
16 Correct 78 ms 2892 KB Output is correct
17 Correct 98 ms 2892 KB Output is correct
18 Correct 78 ms 2892 KB Output is correct
19 Correct 84 ms 2892 KB Output is correct
20 Correct 87 ms 2892 KB Output is correct