# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56516 | 2018-07-11T14:45:01 Z | leejseo | Bali Sculptures (APIO15_sculpture) | C++ | 39 ms | 47488 KB |
#include <bits/stdc++.h> using namespace std; #define UNDEF -1 int L[2001], N, A, B; int M[2001][2001]; long long D[2001][2001]; void input(){ scanf("%d%d%d", &N, &A, &B); memset(M, -1, sizeof(M)); memset(D, -1, sizeof(D)); for (int i=1; i<=N; i++) scanf("%d", &L[i]); for (int i=1; i<=N; i++){ M[i][i] = L[i]; for (int j=i+1; j<=N; j++){ M[i][j] = M[i][j-1] | L[j]; } } } void DP(){ for (int i=1; i<=N; i++){ D[i][1] = M[1][i]; for (int j=2; j<=i; j++){ D[i][j] = D[i-1][j-1] + L[i]; for (int k=1; k<i; k++){ if (D[k][j-1] != UNDEF) D[i][j] = min(D[i][j], D[k][j-1] + M[k+1][i]); } } } } int main(void){ input(); DP(); long long ans = (long long)1e15; for (int i=A; i<=B; i++) ans = min(ans, D[N][i]); printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 37 ms | 47352 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 37 ms | 47452 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 39 ms | 47452 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 38 ms | 47460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 39 ms | 47488 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |