Submission #767754

# Submission time Handle Problem Language Result Execution time Memory
767754 2023-06-27T06:42:32 Z Tob Bali Sculptures (APIO15_sculpture) C++14
100 / 100
133 ms 32044 KB
#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef pair <ll, ll> pii;

const int N = 2e3 + 7;

ll n, a, b;
ll aa[N], ps[N], dp[N][N], dp2[N];

ll Sum(ll x, ll y) {
	if (!x) return ps[y];
	return ps[y] - ps[x-1];
}

int main () {
	cin >> n >> a >> b;
	
	for (int i = 1; i <= n; i++) {
		cin >> aa[i];
		ps[i] = ps[i-1] + aa[i];
	}
	
	if (a > 1) {
		ll cur = 0;
		for (int i = 41; i >= 0; i--) {
			memset(dp, 0, sizeof dp);
			dp[0][0] = 1;
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= j; k++) {
					for (int l = 1; l <= b; l++) {
						if (((Sum(k, j) >> i) & (cur >> i)) == (Sum(k, j) >> i)) dp[j][l] |= dp[k-1][l-1];
					}
				}
			}
			int ok = 0;
			for (int i = a; i <= b; i++) ok |= dp[n][i];
			if (!ok) cur |= (1LL << i);
		}
		cout << cur;
	}
	else {
		ll cur = 0;
		for (int i = 41; i >= 0; i--) {
			for (int j = 1; j <= n; j++) dp2[j] = 1e18;
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= j; k++) {
					if (((Sum(k, j) >> i) & (cur >> i)) == (Sum(k, j) >> i)) {
						dp2[j] = min(dp2[j], dp2[k-1]+1);
					}
				}
			}
			if (dp2[n] > b) cur |= (1LL << i);
		}
		cout << cur;
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 260 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 312 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 308 KB Output is correct
12 Correct 0 ms 304 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 110 ms 31828 KB Output is correct
15 Correct 111 ms 31820 KB Output is correct
16 Correct 111 ms 31804 KB Output is correct
17 Correct 110 ms 31828 KB Output is correct
18 Correct 106 ms 31828 KB Output is correct
19 Correct 110 ms 31828 KB Output is correct
20 Correct 111 ms 31948 KB Output is correct
21 Correct 111 ms 31840 KB Output is correct
22 Correct 112 ms 31828 KB Output is correct
23 Correct 112 ms 31828 KB Output is correct
24 Correct 113 ms 31812 KB Output is correct
25 Correct 110 ms 31796 KB Output is correct
26 Correct 111 ms 31828 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 0 ms 308 KB Output is correct
29 Correct 0 ms 308 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 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 1 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 1 ms 212 KB Output is correct
14 Correct 111 ms 31828 KB Output is correct
15 Correct 109 ms 31820 KB Output is correct
16 Correct 114 ms 31828 KB Output is correct
17 Correct 112 ms 31828 KB Output is correct
18 Correct 111 ms 31828 KB Output is correct
19 Correct 111 ms 31828 KB Output is correct
20 Correct 112 ms 31800 KB Output is correct
21 Correct 114 ms 32044 KB Output is correct
22 Correct 112 ms 31820 KB Output is correct
23 Correct 111 ms 31828 KB Output is correct
24 Correct 108 ms 31828 KB Output is correct
25 Correct 111 ms 31824 KB Output is correct
26 Correct 112 ms 31828 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 312 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
# 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 1 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 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 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 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 1 ms 212 KB Output is correct
20 Correct 1 ms 312 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 308 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 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 308 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 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 312 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 1 ms 212 KB Output is correct
9 Correct 0 ms 304 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 0 ms 304 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 108 ms 31828 KB Output is correct
15 Correct 114 ms 31948 KB Output is correct
16 Correct 114 ms 31788 KB Output is correct
17 Correct 111 ms 31792 KB Output is correct
18 Correct 113 ms 31836 KB Output is correct
19 Correct 112 ms 31828 KB Output is correct
20 Correct 112 ms 31800 KB Output is correct
21 Correct 125 ms 31832 KB Output is correct
22 Correct 114 ms 31828 KB Output is correct
23 Correct 114 ms 31828 KB Output is correct
24 Correct 115 ms 31820 KB Output is correct
25 Correct 115 ms 31820 KB Output is correct
26 Correct 115 ms 31824 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 312 KB Output is correct
30 Correct 0 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 0 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 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 256 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 304 KB Output is correct
47 Correct 1 ms 308 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 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 304 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 300 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 260 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 124 ms 31796 KB Output is correct
65 Correct 115 ms 31824 KB Output is correct
66 Correct 115 ms 31796 KB Output is correct
67 Correct 117 ms 31828 KB Output is correct
68 Correct 124 ms 31948 KB Output is correct
69 Correct 132 ms 31780 KB Output is correct
70 Correct 133 ms 31828 KB Output is correct
71 Correct 116 ms 31828 KB Output is correct
72 Correct 132 ms 31828 KB Output is correct
73 Correct 125 ms 31820 KB Output is correct
74 Correct 128 ms 31828 KB Output is correct
# 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 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 312 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 308 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 308 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 304 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 0 ms 212 KB Output is correct
24 Correct 0 ms 304 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 312 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 212 KB Output is correct
34 Correct 1 ms 308 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 304 KB Output is correct
38 Correct 1 ms 300 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 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 312 KB Output is correct
46 Correct 1 ms 280 KB Output is correct
47 Correct 1 ms 212 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 8 ms 212 KB Output is correct
53 Correct 12 ms 340 KB Output is correct
54 Correct 23 ms 340 KB Output is correct
55 Correct 21 ms 320 KB Output is correct
56 Correct 81 ms 348 KB Output is correct
57 Correct 81 ms 352 KB Output is correct
58 Correct 80 ms 340 KB Output is correct
59 Correct 80 ms 340 KB Output is correct
60 Correct 83 ms 352 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 12 ms 212 KB Output is correct
63 Correct 23 ms 348 KB Output is correct
64 Correct 21 ms 312 KB Output is correct
65 Correct 41 ms 340 KB Output is correct
66 Correct 62 ms 340 KB Output is correct
67 Correct 94 ms 348 KB Output is correct
68 Correct 85 ms 352 KB Output is correct
69 Correct 80 ms 352 KB Output is correct