Submission #1094824

#TimeUsernameProblemLanguageResultExecution timeMemory
1094824Faisal_SaqibBali Sculptures (APIO15_sculpture)C++17
50 / 100
74 ms600 KiB
#include <iostream> #include <set> #include <algorithm> #include <vector> using namespace std; #define ll long long const ll inf=1e18; const ll N=2002; ll pre[N]; ll pw2[50]; ll posa[N]; int main() { int n,a,b; cin>>n>>a>>b; pw2[0]=1; for(int i=1;i<50;i++) pw2[i]=(2ll*pw2[i-1]); for(int i=0;i<n;i++) { cin>>pre[i+1]; pre[i+1]+=pre[i]; } ll pos=pw2[49]-1; for(int i=48;i>=0;i--) { ll new_pos=pos-pw2[i]; posa[0]=0; bool pos1=0; for(int i=1;i<=n;i++) { posa[i]=1e9; for(int k=0;k<i;k++) { ll np=(pre[i]-pre[k]); ll cur_or=(np|new_pos); if(cur_or==new_pos) posa[i]=min(posa[i],posa[k]+1); } if(i==n and posa[i]<=b) { pos1=1; } } if(pos1) pos=new_pos; } cout<<pos<<'\n'; return 0; }
#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...