답안 #585379

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585379 2022-06-28T18:48:36 Z GusterGoose27 Bali Sculptures (APIO15_sculpture) C++11
21 / 100
14 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAXN1 = 100;
bool dp[MAXN1+1][MAXN1+1];
int n, a, b;
int vals[MAXN1];
ll cur = 0;
int bit;

bool works(ll sum) {
	ll sumshift = (sum >> bit);
	ll curshift = (cur >> bit);
	return ((curshift&sumshift) == sumshift);
}

bool possible() {
	for (int i = n; i >= 0; i--) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] = 0;
			if (i == n) {
				dp[i][j] = 1;
				continue;
			}
			if (j > n-i) {
				dp[i][j] = dp[i][n-i];
				continue;
			}
			if (j == 0) {
				continue;
			}
			ll s = 0;
			for (int next = i+1; next <= n; next++) {
				s += vals[next-1];
				if (dp[next][j-1] && works(s)) {
					dp[i][j] = 1;
					break;
				}
			}
		}
	}
	for (int i = a; i <= b; i++)
		if (dp[0][i]) return 1;
	return 0;
}

int main() {
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin >> vals[i];
		cur += vals[i];
	}
	bit = floor(log2(cur));
	cur = 0;
	while (bit >= 0) {
		if (!possible()) { // possible to avoid
			cur += (1ULL << bit);
		}
		bit--;
	}
	cout << cur << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 3 ms 212 KB Output is correct
28 Correct 3 ms 212 KB Output is correct
29 Correct 3 ms 304 KB Output is correct
30 Correct 1 ms 312 KB Output is correct
31 Correct 3 ms 212 KB Output is correct
32 Correct 3 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 224 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 308 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 2 ms 212 KB Output is correct
37 Correct 2 ms 212 KB Output is correct
38 Correct 4 ms 212 KB Output is correct
39 Correct 5 ms 212 KB Output is correct
40 Correct 2 ms 212 KB Output is correct
41 Correct 3 ms 212 KB Output is correct
42 Correct 4 ms 212 KB Output is correct
43 Correct 3 ms 300 KB Output is correct
44 Correct 6 ms 300 KB Output is correct
45 Correct 9 ms 312 KB Output is correct
46 Correct 13 ms 212 KB Output is correct
47 Correct 13 ms 312 KB Output is correct
48 Correct 12 ms 340 KB Output is correct
49 Correct 11 ms 216 KB Output is correct
50 Correct 14 ms 312 KB Output is correct
51 Incorrect 13 ms 316 KB Output isn't correct
52 Halted 0 ms 0 KB -