# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25009 | kdh9949 | Bali Sculptures (APIO15_sculpture) | C++14 | 0 ms | 3620 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (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... |