# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
469955 | 2021-09-02T12:09:20 Z | luciocf | Bali Sculptures (APIO15_sculpture) | C++14 | 1 ms | 332 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e3+10; const ll inf = 1e18; int n; int a[maxn]; ll pref[maxn]; ll dp[maxn][maxn]; int opt[maxn]; void solve(int l, int r, int k) { if (l > r) return; int mid = (l+r)>>1; dp[k][mid] = inf; for (int i = opt[l-1]; i <= min(mid, opt[r+1]); i++) if ((dp[k-1][i-1] | (pref[mid] - pref[i-1])) <= dp[k][mid]) dp[k][mid] = (dp[k-1][i-1] | (pref[mid] - pref[i-1])), opt[mid] = i; solve(l, mid-1, k); solve(mid+1, r, k); } int main(void) { int A, B; scanf("%d %d %d", &n, &A, &B); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); pref[i] = pref[i-1] + 1ll*a[i]; } for (int i = 1; i <= n; i++) dp[0][i] = inf; for (int i = 1; i <= n; i++) { opt[0] = 1, opt[n+1] = n; solve(1, n, i); } ll ans = inf; for (int i = A; i <= B; i++) ans = min(ans, dp[i][n]); printf("%lld\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 304 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 296 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |