| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 185638 | dndhk | Bali Sculptures (APIO15_sculpture) | C++14 | 3 ms | 376 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>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAX_N = 100;
const int INF = 10000000;
int N, A, B;
vector<ll> v;
ll dp[MAX_N+1][MAX_N+1];
ll ans;
ll sum(ll x, ll y){
return dp[1][y] - dp[1][x-1];
}
int main(){
scanf("%d%d%d", &N, &A, &B);
v.pb(0LL);
for(int i=1 ;i<=N; i++){
ll x; scanf("%lld", &x);
v.pb(x);
}
for(int i=1; i<=N; i++){
dp[1][i] = dp[1][i-1] + v[i];
}
for(int k=2; k<=N; k++){
for(int i=k; i<=N; i++){
dp[k][i] = (v[i] | dp[k-1][i-1]);
for(int j=i-1; j>=k-1; j--){
dp[k][i] = min(dp[k][i], (sum(j, i) | dp[k-1][j-1]));
}
//cout<<k<<" "<<i<<" "<<dp[k][i]<<endl;
}
}
ans = dp[A][N];
for(int i=A; i<=B; i++){
ans = min(ans, dp[i][N]);
}
cout<<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... | ||||
