# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551314 | radaiosm7 | Bali Sculptures (APIO15_sculpture) | C++98 | 1 ms | 340 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;
int n, a, b, i, j, k;
long long pref[2005];
long long ar[2005];
long long dp[2005][2005];
long long ans;
int main() {
scanf("%d%d%d", &n, &a, &b);
for (i=1; i <= n; ++i) scanf("%lld", &ar[i]);
pref[0] = 0LL;
for (i=1; i <= n; ++i) pref[i] = pref[i-1]+ar[i];
for (i=0; i <= b; ++i) dp[0][i] = 0;
for (i=2; i <= n; ++i) {
dp[i][1] = pref[i];
for (j=2; j <= b; ++j) {
dp[i][j] = INT_MAX;
for (k=i-1; k >= 0; --k) dp[i][j] = min(dp[i][j], dp[k][j-1]|(pref[i]-pref[k]));
}
}
ans = INT_MAX;
for (i=a; i <= b; ++i) ans = min(ans, dp[n][i]);
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... |