# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40901 | IvanC | Bali Sculptures (APIO15_sculpture) | C++14 | 131 ms | 37992 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;
const int MAXN = 101;
const int MAXOR = 4096;
int dp[MAXN][MAXN][MAXOR],best,N,A,B,soma[MAXN];
int calc(int a,int b){return soma[b] - soma[a-1];}
void solve(int pos,int resta,int curOr){
if(dp[pos][resta][curOr]) return;
dp[pos][resta][curOr] = 1;
if(pos == N + 1){
if(resta != 0) return;
best = min(best,curOr);
return;
}
if(resta == 0) return;
for(int quebra = pos;quebra<=N;quebra++){
solve(quebra+1,resta - 1,curOr | calc(pos,quebra));
}
}
int main(){
scanf("%d %d %d",&N,&A,&B);
for(int i = 1;i<=N;i++){
scanf("%d",&soma[i]);
soma[i] += soma[i-1];
}
best = MAXOR;
for(int i = A;i<=B;i++) solve(1,i,0);
printf("%d\n",best);
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... |