Submission #672278

# Submission time Handle Problem Language Result Execution time Memory
672278 2022-12-15T10:37:42 Z prarie Bali Sculptures (APIO15_sculpture) C++14
50 / 100
233 ms 340 KB
#include <bits/stdc++.h>
 
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define fi first
#define se second
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define compress(v) sort(all(v)), (v).erase(unique(all((v))), v.end())
#define pb push_back
#define eb emplace_back
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
 
template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }
template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

int main() {
	fastio;
	int N, A, B;
	cin >> N >> A >> B;
	vector<int> Y(N);
	for (auto &y : Y) {
		cin >> y;
	}

	auto check = [&](ll R) -> bool {
		if (A == 1) {
			vector<int> dp(N + 1, int(1e9));
			dp[0] = 0;
			for (int i = 0; i < N; i++) {
				ll sum = 0;
				for (int j = i; j >= 0; j--) {
					sum += Y[j];
					if (!(sum & (~R))) {
						dp[i + 1] = min(dp[i + 1], dp[j] + 1);
					}
				}
			}
			return dp[N] <= B;
		}

		vector<vector<int>> dp(N + 1, vector<int>(N + 1));
		dp[0][0] = 1;
		for (int i = 0; i < N; i++) {
			ll sum = 0;
			for (int g = 0; g < N; g++) {
				for (int j = i; j >= 0; j--) {
					sum += Y[j];
					if (!(sum & (~R)) && dp[j][g]) {
						dp[i + 1][g + 1] = 1;
					}
				}
			}
		}

		for (int g = A; g <= B; g++) {
			if (dp[N][g]) {
				return true;
			}
		}
		return false;
	};

	ll ans = 0;
	for (int b = 60; b >= 0; b--) {
		ll R = ans | ((1LL << b) - 1);
		if (!check(R)) {
			ans |= (1LL << b);
		}
	}

	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 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 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 324 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 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 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 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 1 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 1 ms 212 KB Output is correct
15 Correct 0 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 1 ms 212 KB Output is correct
20 Correct 1 ms 316 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 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 324 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 0 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 324 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 320 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 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 324 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 1 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 320 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 320 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 320 KB Output is correct
38 Correct 2 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 2 ms 212 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 1 ms 320 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 320 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 22 ms 332 KB Output is correct
53 Correct 33 ms 212 KB Output is correct
54 Correct 68 ms 340 KB Output is correct
55 Correct 60 ms 212 KB Output is correct
56 Correct 223 ms 336 KB Output is correct
57 Correct 224 ms 340 KB Output is correct
58 Correct 233 ms 340 KB Output is correct
59 Correct 221 ms 340 KB Output is correct
60 Correct 230 ms 336 KB Output is correct
61 Correct 2 ms 212 KB Output is correct
62 Correct 34 ms 320 KB Output is correct
63 Correct 61 ms 320 KB Output is correct
64 Correct 58 ms 340 KB Output is correct
65 Correct 112 ms 340 KB Output is correct
66 Correct 175 ms 328 KB Output is correct
67 Correct 223 ms 340 KB Output is correct
68 Correct 227 ms 340 KB Output is correct
69 Correct 229 ms 340 KB Output is correct