# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106366 | Hideo | Bali Sculptures (APIO15_sculpture) | C++14 | 637 ms | 263168 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;
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, int >
#define pii pair < int, pi >
#define vii vector < pi >
const int N = 107;
const int INF = 1e9 + 7;
ll dp[N][N], pr[N], x[N], ans;
int n, a, b;
vii v[N];
main(){
ans = INF;
cin >> n >> a >> b;
for (int i = 1; i <= n; i++){
scanf("%d", &x[i]);
pr[i] = pr[i - 1] + x[i];
}
for (int i = 1; i < N; i++)
for (int j = 0; j < N; j++)
dp[i][j] = INF;
v[0].pb(mk(0, 0));
for (int i = 1; i <= n; i++){
for (int g = 1; g <= min(i, b); g++){
for (pi to : v[g - 1]){
v[g].pb(mk((to.fr | (pr[i] - pr[to.sc])), i));
dp[i][g] = min(dp[i][g], (to.fr | (pr[i] - pr[to.sc])));
}
}
}
for (int i = a; i <= b; i++)
ans = min(ans, dp[n][i]);
cout << ans;
}
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... |