# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1165529 | thinknoexit | Bali Sculptures (APIO15_sculpture) | C++20 | 60 ms | 328 KiB |
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dp[2020];
ll qs[2020];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, a, b;
cin >> n >> a >> b;
for (int i = 1;i <= n;i++) {
int x;
cin >> x;
qs[i] = qs[i - 1] + x;
}
if (a == 1) {
ll ans = (1ll << 41) - 1;
for (ll j = 40;j >= 0;j--) {
memset(dp, 0x3f, sizeof dp);
dp[0] = 0;
ans ^= (1ll << j);
for (int i = 1;i <= n;i++) {
for (int j = 0;j < i;j++) {
if (((qs[i] - qs[j]) | ans) == ans) {
dp[i] = min(dp[i], dp[j] + 1);
}
}
}
if (dp[n] > b) ans ^= (1ll << j);
}
cout << ans << '\n';
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |