| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1292982 | dm10r7 | Bali Sculptures (APIO15_sculpture) | C++20 | 578 ms | 948 KiB |
#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
bitset<N> dp[N];
long long pref[N];
long long a[N];
int main() {
int n, l, r;
scanf("%d %d %d", &n, &l, &r);
for(int i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
pref[i] = pref[i - 1] + a[i];
}
long long ans = (1LL << 45) - 1;
for(long long bit = 1LL << 44; bit; bit >>= 1) {
ans ^= bit;
for(int i = 0; i <= n; i++) dp[i].reset();
dp[0][0] = 1;
for(int i = 0; i < n; i++) {
if(dp[i].none()) continue;
long long sum = pref[i];
for(int j = i + 1; j <= n; j++) {
long long val = pref[j] - sum;
if(val > ans) break;
if((val & ans) == val) {
dp[j] |= (dp[i] << 1);
}
}
}
bool ok = 0;
for(int cnt = l; cnt <= r; cnt++) {
if(dp[n][cnt]) { ok = 1; break; }
}
if(!ok) ans |= bit;
}
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
| # | 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... | ||||
