답안 #463887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
463887 2021-08-12T01:05:16 Z Hamed5001 Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 16196 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int mxN = 2e3+10;
int dp1[mxN], dp2[mxN][mxN];
int N, A, B;
int Y[mxN];
ll msk, ans;

int fun2(int idx, int grp) {
	if (grp > B)
		return 0;
	if (idx == N)
		return (A <= grp && grp <= B);

	int &ret = dp2[idx][grp];
	if (~ret) return ret;

	ret = 0;
	ll sum = 0;
	for (int i = idx; i < N; ++i) {
		sum += Y[i];
		if (!(sum & msk))
			ret |= fun2(i+1, grp+1);
	}

	return ret;
}

bool check2() {
	memset(dp2, -1, sizeof dp2);
	return fun2(0, 0);
}

// void solve1() {
// 	for (int bit = 50; bit >= 0; --bit) {
// 		msk |= (1 << bit);
// 		if (!check1())
// 			msk ^= (1 << bit), ans |= (1 << bit);
// 	}
// }

void solve2() {
	for (int bit = 50; bit >= 0; --bit) {
		msk |= (1LL << bit);
		if (!check2())
			msk ^= (1LL << bit), ans |= (1LL << bit);
	}
	cout << ans << endl;
}

void solve() {
	cin >> N >> A >> B;
	for (int i = 0; i < N; ++i)
		cin >> Y[i];
	// if (A == 1) {
	// 	solve1();
	// }
	// else {
		solve2();
	// }
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 16076 KB Output is correct
2 Correct 106 ms 16056 KB Output is correct
3 Correct 105 ms 16076 KB Output is correct
4 Correct 113 ms 16112 KB Output is correct
5 Correct 109 ms 16116 KB Output is correct
6 Correct 116 ms 16112 KB Output is correct
7 Correct 107 ms 16076 KB Output is correct
8 Correct 99 ms 16076 KB Output is correct
9 Correct 103 ms 16112 KB Output is correct
10 Correct 108 ms 16112 KB Output is correct
11 Correct 108 ms 16116 KB Output is correct
12 Correct 109 ms 16116 KB Output is correct
13 Correct 113 ms 16076 KB Output is correct
14 Correct 114 ms 16108 KB Output is correct
15 Correct 108 ms 16044 KB Output is correct
16 Correct 110 ms 16112 KB Output is correct
17 Correct 106 ms 16124 KB Output is correct
18 Correct 112 ms 16116 KB Output is correct
19 Correct 108 ms 16116 KB Output is correct
20 Correct 108 ms 16056 KB Output is correct
21 Correct 107 ms 16108 KB Output is correct
22 Correct 110 ms 16108 KB Output is correct
23 Correct 108 ms 16116 KB Output is correct
24 Correct 110 ms 16112 KB Output is correct
25 Correct 110 ms 16112 KB Output is correct
26 Correct 108 ms 16108 KB Output is correct
27 Correct 114 ms 16104 KB Output is correct
28 Correct 112 ms 16112 KB Output is correct
29 Correct 110 ms 16112 KB Output is correct
30 Correct 109 ms 16076 KB Output is correct
31 Correct 110 ms 16076 KB Output is correct
32 Correct 107 ms 16124 KB Output is correct
33 Correct 106 ms 16108 KB Output is correct
34 Correct 111 ms 16076 KB Output is correct
35 Correct 118 ms 16076 KB Output is correct
36 Correct 110 ms 16112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 16116 KB Output is correct
2 Correct 109 ms 16116 KB Output is correct
3 Correct 114 ms 16108 KB Output is correct
4 Correct 115 ms 16076 KB Output is correct
5 Correct 110 ms 16116 KB Output is correct
6 Correct 116 ms 16112 KB Output is correct
7 Correct 120 ms 16112 KB Output is correct
8 Correct 115 ms 16112 KB Output is correct
9 Correct 105 ms 16108 KB Output is correct
10 Correct 108 ms 16076 KB Output is correct
11 Correct 107 ms 16112 KB Output is correct
12 Correct 108 ms 16112 KB Output is correct
13 Correct 114 ms 16076 KB Output is correct
14 Correct 108 ms 16076 KB Output is correct
15 Correct 107 ms 16076 KB Output is correct
16 Correct 110 ms 16112 KB Output is correct
17 Correct 111 ms 16112 KB Output is correct
18 Correct 106 ms 16076 KB Output is correct
19 Correct 108 ms 16112 KB Output is correct
20 Correct 109 ms 16108 KB Output is correct
21 Correct 114 ms 16108 KB Output is correct
22 Correct 113 ms 16076 KB Output is correct
23 Correct 103 ms 16076 KB Output is correct
24 Correct 107 ms 16112 KB Output is correct
25 Correct 109 ms 16076 KB Output is correct
26 Correct 110 ms 16112 KB Output is correct
27 Correct 105 ms 16076 KB Output is correct
28 Correct 108 ms 16108 KB Output is correct
29 Correct 109 ms 16076 KB Output is correct
30 Correct 110 ms 16116 KB Output is correct
31 Correct 111 ms 16076 KB Output is correct
32 Correct 110 ms 16112 KB Output is correct
33 Correct 108 ms 16116 KB Output is correct
34 Correct 113 ms 16112 KB Output is correct
35 Correct 111 ms 16108 KB Output is correct
36 Correct 108 ms 16076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 16076 KB Output is correct
2 Correct 108 ms 16076 KB Output is correct
3 Correct 108 ms 16076 KB Output is correct
4 Correct 106 ms 16112 KB Output is correct
5 Correct 111 ms 16076 KB Output is correct
6 Correct 107 ms 16108 KB Output is correct
7 Correct 106 ms 16104 KB Output is correct
8 Correct 107 ms 16076 KB Output is correct
9 Correct 105 ms 16076 KB Output is correct
10 Correct 104 ms 16076 KB Output is correct
11 Correct 106 ms 16108 KB Output is correct
12 Correct 111 ms 16116 KB Output is correct
13 Correct 108 ms 16112 KB Output is correct
14 Correct 107 ms 16076 KB Output is correct
15 Correct 108 ms 16076 KB Output is correct
16 Correct 109 ms 16076 KB Output is correct
17 Correct 109 ms 16124 KB Output is correct
18 Correct 116 ms 16108 KB Output is correct
19 Correct 119 ms 16076 KB Output is correct
20 Correct 112 ms 16116 KB Output is correct
21 Correct 114 ms 16076 KB Output is correct
22 Correct 119 ms 16112 KB Output is correct
23 Correct 117 ms 16112 KB Output is correct
24 Correct 117 ms 16108 KB Output is correct
25 Correct 120 ms 16116 KB Output is correct
26 Correct 123 ms 16116 KB Output is correct
27 Correct 144 ms 16112 KB Output is correct
28 Correct 164 ms 16116 KB Output is correct
29 Correct 157 ms 16116 KB Output is correct
30 Correct 111 ms 16112 KB Output is correct
31 Correct 150 ms 16076 KB Output is correct
32 Correct 165 ms 16120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 16096 KB Output is correct
2 Correct 109 ms 16112 KB Output is correct
3 Correct 107 ms 16116 KB Output is correct
4 Correct 108 ms 16116 KB Output is correct
5 Correct 113 ms 16076 KB Output is correct
6 Correct 107 ms 16076 KB Output is correct
7 Correct 107 ms 16116 KB Output is correct
8 Correct 106 ms 16076 KB Output is correct
9 Correct 106 ms 16076 KB Output is correct
10 Correct 113 ms 16108 KB Output is correct
11 Correct 109 ms 16112 KB Output is correct
12 Correct 107 ms 16076 KB Output is correct
13 Correct 105 ms 16076 KB Output is correct
14 Correct 110 ms 16112 KB Output is correct
15 Correct 109 ms 16124 KB Output is correct
16 Correct 112 ms 16008 KB Output is correct
17 Correct 108 ms 16112 KB Output is correct
18 Correct 109 ms 16076 KB Output is correct
19 Correct 109 ms 16116 KB Output is correct
20 Correct 112 ms 16112 KB Output is correct
21 Correct 105 ms 16076 KB Output is correct
22 Correct 106 ms 16112 KB Output is correct
23 Correct 106 ms 16112 KB Output is correct
24 Correct 103 ms 16112 KB Output is correct
25 Correct 104 ms 16124 KB Output is correct
26 Correct 108 ms 16112 KB Output is correct
27 Correct 109 ms 16108 KB Output is correct
28 Correct 105 ms 16076 KB Output is correct
29 Correct 105 ms 16112 KB Output is correct
30 Correct 105 ms 16112 KB Output is correct
31 Correct 112 ms 16112 KB Output is correct
32 Correct 106 ms 16112 KB Output is correct
33 Correct 105 ms 16112 KB Output is correct
34 Correct 109 ms 16108 KB Output is correct
35 Correct 109 ms 16124 KB Output is correct
36 Correct 105 ms 16108 KB Output is correct
37 Correct 105 ms 16108 KB Output is correct
38 Correct 106 ms 16112 KB Output is correct
39 Correct 107 ms 16116 KB Output is correct
40 Correct 110 ms 16108 KB Output is correct
41 Correct 112 ms 16120 KB Output is correct
42 Correct 114 ms 16112 KB Output is correct
43 Correct 106 ms 16076 KB Output is correct
44 Correct 114 ms 16112 KB Output is correct
45 Correct 115 ms 16076 KB Output is correct
46 Correct 111 ms 16124 KB Output is correct
47 Correct 118 ms 16008 KB Output is correct
48 Correct 115 ms 16108 KB Output is correct
49 Correct 121 ms 16116 KB Output is correct
50 Correct 141 ms 16120 KB Output is correct
51 Correct 165 ms 16076 KB Output is correct
52 Correct 160 ms 16116 KB Output is correct
53 Correct 108 ms 16112 KB Output is correct
54 Correct 150 ms 16132 KB Output is correct
55 Correct 160 ms 16116 KB Output is correct
56 Correct 116 ms 16112 KB Output is correct
57 Correct 116 ms 16112 KB Output is correct
58 Correct 128 ms 16112 KB Output is correct
59 Correct 127 ms 16116 KB Output is correct
60 Correct 130 ms 16012 KB Output is correct
61 Correct 115 ms 16112 KB Output is correct
62 Correct 135 ms 16112 KB Output is correct
63 Correct 131 ms 16196 KB Output is correct
64 Correct 151 ms 16112 KB Output is correct
65 Correct 111 ms 16108 KB Output is correct
66 Correct 116 ms 16076 KB Output is correct
67 Correct 116 ms 16108 KB Output is correct
68 Correct 123 ms 16112 KB Output is correct
69 Correct 138 ms 16120 KB Output is correct
70 Correct 128 ms 16120 KB Output is correct
71 Correct 108 ms 16112 KB Output is correct
72 Correct 146 ms 16116 KB Output is correct
73 Correct 129 ms 16112 KB Output is correct
74 Correct 131 ms 16116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 16076 KB Output is correct
2 Correct 108 ms 16076 KB Output is correct
3 Correct 105 ms 16112 KB Output is correct
4 Correct 108 ms 16112 KB Output is correct
5 Correct 106 ms 16080 KB Output is correct
6 Correct 109 ms 16172 KB Output is correct
7 Correct 105 ms 16116 KB Output is correct
8 Correct 108 ms 16116 KB Output is correct
9 Correct 107 ms 16076 KB Output is correct
10 Correct 106 ms 16116 KB Output is correct
11 Correct 108 ms 16096 KB Output is correct
12 Correct 112 ms 16112 KB Output is correct
13 Correct 105 ms 16112 KB Output is correct
14 Correct 109 ms 16108 KB Output is correct
15 Correct 104 ms 16076 KB Output is correct
16 Correct 107 ms 16116 KB Output is correct
17 Correct 110 ms 16076 KB Output is correct
18 Correct 107 ms 16108 KB Output is correct
19 Correct 112 ms 16112 KB Output is correct
20 Correct 109 ms 16056 KB Output is correct
21 Correct 105 ms 16048 KB Output is correct
22 Correct 118 ms 16116 KB Output is correct
23 Correct 110 ms 16112 KB Output is correct
24 Correct 110 ms 16108 KB Output is correct
25 Correct 111 ms 16076 KB Output is correct
26 Correct 114 ms 16108 KB Output is correct
27 Correct 113 ms 16108 KB Output is correct
28 Correct 115 ms 16076 KB Output is correct
29 Correct 124 ms 16108 KB Output is correct
30 Correct 110 ms 16108 KB Output is correct
31 Correct 114 ms 16112 KB Output is correct
32 Correct 115 ms 16012 KB Output is correct
33 Correct 114 ms 16108 KB Output is correct
34 Correct 114 ms 16128 KB Output is correct
35 Correct 110 ms 16116 KB Output is correct
36 Correct 131 ms 16196 KB Output is correct
37 Correct 143 ms 16040 KB Output is correct
38 Correct 176 ms 16076 KB Output is correct
39 Correct 165 ms 16128 KB Output is correct
40 Correct 114 ms 16112 KB Output is correct
41 Correct 152 ms 16076 KB Output is correct
42 Correct 166 ms 16044 KB Output is correct
43 Correct 113 ms 16112 KB Output is correct
44 Correct 112 ms 16112 KB Output is correct
45 Correct 123 ms 16108 KB Output is correct
46 Correct 132 ms 16112 KB Output is correct
47 Correct 140 ms 16116 KB Output is correct
48 Correct 113 ms 16076 KB Output is correct
49 Correct 132 ms 16116 KB Output is correct
50 Correct 145 ms 16112 KB Output is correct
51 Correct 128 ms 16076 KB Output is correct
52 Execution timed out 1086 ms 16076 KB Time limit exceeded
53 Halted 0 ms 0 KB -