답안 #87777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87777 2018-12-02T13:19:51 Z KCSC Bali Sculptures (APIO15_sculpture) C++14
100 / 100
158 ms 2340 KB
#include <bits/stdc++.h>
using namespace std;

const int DIM = 2005;

int dp1[DIM]; long long psm[DIM];
bool dp2[DIM][DIM];

bool solve(long long val, int n, int a, int b) {
	long long aux = ((1LL << 50) - 1) ^ val;
	if (a == 1) {
		dp1[0] = 0;	
		for (int i = 1; i <= n; ++i) {
			dp1[i] = b + 1;
			for (int j = i; j >= 1; --j) {
				if (!((psm[i] - psm[j - 1]) & aux)) {
					dp1[i] = min(dp1[i], dp1[j - 1] + 1); } } }
		return dp1[n] <= b; }
	else {
		dp2[0][0] = true;
		for (int k = 1; k <= b; ++k) {	
			for (int i = 1; i <= n; ++i) {
				dp2[k][i] = false;	
				for (int j = i; j >= 1; --j) {
					if (!((psm[i] - psm[j - 1]) & aux)) {
						dp2[k][i] |= dp2[k - 1][j - 1]; } } } }
		for (int k = a; k <= b; ++k) {
			if (dp2[k][n]) { 
				return true; } }
		return false; } }

int main(void) {
#ifdef HOME
	freopen("sculpture.in", "r", stdin);
	freopen("sculpture.out", "w", stdout);
#endif
	int n, a, b; cin >> n >> a >> b;	
	for (int i = 1; i <= n; ++i) {
		cin >> psm[i]; psm[i] += psm[i - 1]; }
	long long ans = 0;
	for (long long i = (1LL << 49); i; i >>= 1) {
		if (!solve(ans ^ (i - 1), n, a, b)) {
			ans ^= i; } }
	cout << ans;
	return 0; }
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 616 KB Output is correct
4 Correct 2 ms 616 KB Output is correct
5 Correct 2 ms 616 KB Output is correct
6 Correct 15 ms 616 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 740 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 2 ms 744 KB Output is correct
11 Correct 3 ms 752 KB Output is correct
12 Correct 2 ms 756 KB Output is correct
13 Correct 2 ms 760 KB Output is correct
14 Correct 2 ms 764 KB Output is correct
15 Correct 2 ms 764 KB Output is correct
16 Correct 2 ms 772 KB Output is correct
17 Correct 2 ms 796 KB Output is correct
18 Correct 2 ms 800 KB Output is correct
19 Correct 3 ms 804 KB Output is correct
20 Correct 2 ms 812 KB Output is correct
21 Correct 0 ms 816 KB Output is correct
22 Correct 2 ms 820 KB Output is correct
23 Correct 3 ms 824 KB Output is correct
24 Correct 2 ms 828 KB Output is correct
25 Correct 3 ms 832 KB Output is correct
26 Correct 4 ms 836 KB Output is correct
27 Correct 2 ms 840 KB Output is correct
28 Correct 2 ms 844 KB Output is correct
29 Correct 3 ms 848 KB Output is correct
30 Correct 3 ms 852 KB Output is correct
31 Correct 3 ms 856 KB Output is correct
32 Correct 0 ms 860 KB Output is correct
33 Correct 1 ms 864 KB Output is correct
34 Correct 3 ms 868 KB Output is correct
35 Correct 2 ms 872 KB Output is correct
36 Correct 2 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 880 KB Output is correct
2 Correct 2 ms 888 KB Output is correct
3 Correct 2 ms 888 KB Output is correct
4 Correct 3 ms 892 KB Output is correct
5 Correct 2 ms 896 KB Output is correct
6 Correct 3 ms 904 KB Output is correct
7 Correct 2 ms 904 KB Output is correct
8 Correct 2 ms 908 KB Output is correct
9 Correct 2 ms 912 KB Output is correct
10 Correct 2 ms 916 KB Output is correct
11 Correct 2 ms 920 KB Output is correct
12 Correct 2 ms 924 KB Output is correct
13 Correct 2 ms 928 KB Output is correct
14 Correct 2 ms 932 KB Output is correct
15 Correct 2 ms 936 KB Output is correct
16 Correct 2 ms 940 KB Output is correct
17 Correct 2 ms 944 KB Output is correct
18 Correct 2 ms 948 KB Output is correct
19 Correct 2 ms 952 KB Output is correct
20 Correct 2 ms 956 KB Output is correct
21 Correct 3 ms 960 KB Output is correct
22 Correct 2 ms 964 KB Output is correct
23 Correct 2 ms 968 KB Output is correct
24 Correct 3 ms 972 KB Output is correct
25 Correct 2 ms 976 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 2 ms 984 KB Output is correct
28 Correct 3 ms 988 KB Output is correct
29 Correct 2 ms 992 KB Output is correct
30 Correct 2 ms 992 KB Output is correct
31 Correct 3 ms 1004 KB Output is correct
32 Correct 1 ms 1004 KB Output is correct
33 Correct 3 ms 1008 KB Output is correct
34 Correct 3 ms 1012 KB Output is correct
35 Correct 2 ms 1016 KB Output is correct
36 Correct 3 ms 1020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1156 KB Output is correct
2 Correct 2 ms 1160 KB Output is correct
3 Correct 2 ms 1196 KB Output is correct
4 Correct 2 ms 1200 KB Output is correct
5 Correct 3 ms 1208 KB Output is correct
6 Correct 3 ms 1208 KB Output is correct
7 Correct 2 ms 1216 KB Output is correct
8 Correct 2 ms 1220 KB Output is correct
9 Correct 2 ms 1224 KB Output is correct
10 Correct 2 ms 1224 KB Output is correct
11 Correct 2 ms 1232 KB Output is correct
12 Correct 2 ms 1236 KB Output is correct
13 Correct 2 ms 1236 KB Output is correct
14 Correct 1 ms 1244 KB Output is correct
15 Correct 2 ms 1248 KB Output is correct
16 Correct 2 ms 1252 KB Output is correct
17 Correct 3 ms 1256 KB Output is correct
18 Correct 2 ms 1256 KB Output is correct
19 Correct 3 ms 1264 KB Output is correct
20 Correct 2 ms 1276 KB Output is correct
21 Correct 3 ms 1276 KB Output is correct
22 Correct 2 ms 1396 KB Output is correct
23 Correct 3 ms 1396 KB Output is correct
24 Correct 3 ms 1396 KB Output is correct
25 Correct 3 ms 1396 KB Output is correct
26 Correct 3 ms 1396 KB Output is correct
27 Correct 3 ms 1396 KB Output is correct
28 Correct 3 ms 1396 KB Output is correct
29 Correct 3 ms 1396 KB Output is correct
30 Correct 3 ms 1396 KB Output is correct
31 Correct 3 ms 1396 KB Output is correct
32 Correct 3 ms 1396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1396 KB Output is correct
2 Correct 3 ms 1396 KB Output is correct
3 Correct 3 ms 1396 KB Output is correct
4 Correct 2 ms 1396 KB Output is correct
5 Correct 3 ms 1396 KB Output is correct
6 Correct 3 ms 1396 KB Output is correct
7 Correct 3 ms 1396 KB Output is correct
8 Correct 3 ms 1396 KB Output is correct
9 Correct 2 ms 1396 KB Output is correct
10 Correct 2 ms 1396 KB Output is correct
11 Correct 2 ms 1400 KB Output is correct
12 Correct 2 ms 1404 KB Output is correct
13 Correct 2 ms 1408 KB Output is correct
14 Correct 2 ms 1412 KB Output is correct
15 Correct 2 ms 1412 KB Output is correct
16 Correct 2 ms 1420 KB Output is correct
17 Correct 2 ms 1424 KB Output is correct
18 Correct 2 ms 1428 KB Output is correct
19 Correct 2 ms 1432 KB Output is correct
20 Correct 3 ms 1436 KB Output is correct
21 Correct 3 ms 1440 KB Output is correct
22 Correct 3 ms 1444 KB Output is correct
23 Correct 3 ms 1448 KB Output is correct
24 Correct 3 ms 1456 KB Output is correct
25 Correct 3 ms 1460 KB Output is correct
26 Correct 2 ms 1464 KB Output is correct
27 Correct 2 ms 1468 KB Output is correct
28 Correct 2 ms 1472 KB Output is correct
29 Correct 2 ms 1600 KB Output is correct
30 Correct 7 ms 1600 KB Output is correct
31 Correct 2 ms 1600 KB Output is correct
32 Correct 2 ms 1600 KB Output is correct
33 Correct 2 ms 1600 KB Output is correct
34 Correct 2 ms 1600 KB Output is correct
35 Correct 3 ms 1600 KB Output is correct
36 Correct 3 ms 1600 KB Output is correct
37 Correct 3 ms 1600 KB Output is correct
38 Correct 2 ms 1600 KB Output is correct
39 Correct 3 ms 1600 KB Output is correct
40 Correct 3 ms 1600 KB Output is correct
41 Correct 2 ms 1668 KB Output is correct
42 Correct 3 ms 1668 KB Output is correct
43 Correct 3 ms 1668 KB Output is correct
44 Correct 3 ms 1668 KB Output is correct
45 Correct 3 ms 1668 KB Output is correct
46 Correct 3 ms 1668 KB Output is correct
47 Correct 3 ms 1668 KB Output is correct
48 Correct 3 ms 1668 KB Output is correct
49 Correct 3 ms 1668 KB Output is correct
50 Correct 3 ms 1668 KB Output is correct
51 Correct 3 ms 1668 KB Output is correct
52 Correct 3 ms 1668 KB Output is correct
53 Correct 3 ms 1668 KB Output is correct
54 Correct 3 ms 1668 KB Output is correct
55 Correct 3 ms 1668 KB Output is correct
56 Correct 3 ms 1668 KB Output is correct
57 Correct 3 ms 1668 KB Output is correct
58 Correct 3 ms 1668 KB Output is correct
59 Correct 3 ms 1668 KB Output is correct
60 Correct 3 ms 1668 KB Output is correct
61 Correct 3 ms 1668 KB Output is correct
62 Correct 3 ms 1676 KB Output is correct
63 Correct 3 ms 1680 KB Output is correct
64 Correct 39 ms 1812 KB Output is correct
65 Correct 5 ms 1812 KB Output is correct
66 Correct 5 ms 1812 KB Output is correct
67 Correct 11 ms 1812 KB Output is correct
68 Correct 21 ms 1832 KB Output is correct
69 Correct 42 ms 1964 KB Output is correct
70 Correct 40 ms 1968 KB Output is correct
71 Correct 4 ms 1968 KB Output is correct
72 Correct 44 ms 1968 KB Output is correct
73 Correct 32 ms 1968 KB Output is correct
74 Correct 30 ms 1968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1968 KB Output is correct
2 Correct 3 ms 1968 KB Output is correct
3 Correct 2 ms 1968 KB Output is correct
4 Correct 3 ms 1968 KB Output is correct
5 Correct 2 ms 1968 KB Output is correct
6 Correct 2 ms 1968 KB Output is correct
7 Correct 3 ms 1968 KB Output is correct
8 Correct 2 ms 1968 KB Output is correct
9 Correct 2 ms 1968 KB Output is correct
10 Correct 2 ms 1968 KB Output is correct
11 Correct 0 ms 1968 KB Output is correct
12 Correct 3 ms 1968 KB Output is correct
13 Correct 2 ms 1968 KB Output is correct
14 Correct 3 ms 1968 KB Output is correct
15 Correct 2 ms 1968 KB Output is correct
16 Correct 3 ms 1968 KB Output is correct
17 Correct 3 ms 1968 KB Output is correct
18 Correct 3 ms 1968 KB Output is correct
19 Correct 3 ms 1968 KB Output is correct
20 Correct 3 ms 1968 KB Output is correct
21 Correct 3 ms 1968 KB Output is correct
22 Correct 3 ms 1968 KB Output is correct
23 Correct 2 ms 1968 KB Output is correct
24 Correct 1 ms 1968 KB Output is correct
25 Correct 3 ms 1968 KB Output is correct
26 Correct 2 ms 1968 KB Output is correct
27 Correct 2 ms 1968 KB Output is correct
28 Correct 2 ms 1968 KB Output is correct
29 Correct 2 ms 1968 KB Output is correct
30 Correct 2 ms 1968 KB Output is correct
31 Correct 3 ms 1968 KB Output is correct
32 Correct 2 ms 1968 KB Output is correct
33 Correct 3 ms 1968 KB Output is correct
34 Correct 3 ms 1968 KB Output is correct
35 Correct 3 ms 2028 KB Output is correct
36 Correct 3 ms 2028 KB Output is correct
37 Correct 3 ms 2028 KB Output is correct
38 Correct 3 ms 2028 KB Output is correct
39 Correct 3 ms 2028 KB Output is correct
40 Correct 3 ms 2052 KB Output is correct
41 Correct 2 ms 2052 KB Output is correct
42 Correct 3 ms 2052 KB Output is correct
43 Correct 3 ms 2052 KB Output is correct
44 Correct 3 ms 2052 KB Output is correct
45 Correct 3 ms 2052 KB Output is correct
46 Correct 3 ms 2112 KB Output is correct
47 Correct 3 ms 2112 KB Output is correct
48 Correct 3 ms 2112 KB Output is correct
49 Correct 3 ms 2112 KB Output is correct
50 Correct 2 ms 2112 KB Output is correct
51 Correct 3 ms 2112 KB Output is correct
52 Correct 17 ms 2112 KB Output is correct
53 Correct 25 ms 2112 KB Output is correct
54 Correct 45 ms 2112 KB Output is correct
55 Correct 41 ms 2112 KB Output is correct
56 Correct 148 ms 2232 KB Output is correct
57 Correct 157 ms 2232 KB Output is correct
58 Correct 147 ms 2232 KB Output is correct
59 Correct 148 ms 2232 KB Output is correct
60 Correct 158 ms 2232 KB Output is correct
61 Correct 3 ms 2232 KB Output is correct
62 Correct 25 ms 2232 KB Output is correct
63 Correct 46 ms 2244 KB Output is correct
64 Correct 42 ms 2244 KB Output is correct
65 Correct 139 ms 2292 KB Output is correct
66 Correct 119 ms 2308 KB Output is correct
67 Correct 151 ms 2308 KB Output is correct
68 Correct 155 ms 2308 KB Output is correct
69 Correct 151 ms 2340 KB Output is correct