Submission #620577

#TimeUsernameProblemLanguageResultExecution timeMemory
620577daisy2Bali Sculptures (APIO15_sculpture)C++14
0 / 100
1 ms324 KiB
#include<iostream> #define endl '\n' using namespace std; long long n,a,b,m[2005],pref[2005]; const long long MAXIM=1000000000000; long long fin(int p,long long tr,int brg) { if(p==0) { if(brg>=a && brg<=b) {return 0;} return MAXIM; } long long r=MAXIM,trn; for(int i=p-1;i>=0;i--) { trn=tr|(pref[p]-pref[i]); r=min((fin(i,trn,brg+1)|trn),r); } return r; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>a>>b; for(int i=1;i<=n;i++) { cin>>m[i]; pref[i]=m[i]+pref[i-1]; } if(a==1) { cout<<pref[n]<<endl; return 0; } cout<<fin(n,0,0)<<endl; } /* 6 1 3 8 1 2 1 5 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...