# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25009 | 2017-06-20T03:42:31 Z | kdh9949 | Bali Sculptures (APIO15_sculpture) | C++14 | 0 ms | 3620 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll inf = 1e18; int n, a, b; ll s[2010], dp[101][2010], ans = inf; int main(){ scanf("%d%d%d", &n, &a, &b); for(int i = 1; i <= n; i++){ scanf("%lld", s + i); s[i] += s[i - 1]; } if(n <= 100){ fill(dp[0] + 1, dp[0] + n + 1, inf); for(int i = 1; i <= b; i++){ for(int j = i; j <= n; j++){ dp[i][j] = inf; for(int k = i - 1; k < j; k++){ dp[i][j] = min(dp[i][j], dp[i - 1][k] | (s[j] - s[k])); } } } for(int i = a; i <= b; i++) ans = min(ans, dp[i][n]); printf("%lld\n", ans); } else{ for(int i = 1; i <= n; i++){ dp[0][i] = inf; for(int j = 0; j < i; j++){ dp[0][i] = min(dp[0][i], dp[0][j] | (s[i] - s[j])); } } printf("%lld\n", dp[0][n]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3620 KB | Output is correct |
2 | Incorrect | 0 ms | 3620 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3620 KB | Output is correct |
2 | Incorrect | 0 ms | 3620 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3620 KB | Output is correct |
2 | Incorrect | 0 ms | 3620 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3620 KB | Output is correct |
2 | Incorrect | 0 ms | 3620 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3620 KB | Output is correct |
2 | Incorrect | 0 ms | 3620 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |