Submission #113132

#TimeUsernameProblemLanguageResultExecution timeMemory
113132ioilolcomBali Sculptures (APIO15_sculpture)C++14
21 / 100
4 ms512 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" typedef long long int ll; vector<ll> v; int n; const int N=107; ll pre[N]; ll dp[N][N]; ll query(int l,int r){ return pre[r]-pre[l-1]; } ll solve(int idx,int k){ if(idx==n+1) { if(k==0) { return 0; } return 1e9; } if(dp[idx][k]!=-1) return dp[idx][k]; ll ans=1e9; for(int j=idx; j<=n; j++) { ans=min(ans,query(idx,j) | solve(j+1,k-1)); } return dp[idx][k]=ans; } int main() { ios_base:: sync_with_stdio(false); cin.tie(0); cin>>n; int a,b; cin>>a>>b; v.resize(n+1); for(int i=1; i<=n; i++) { cin>>v[i]; pre[i]=pre[i-1]+v[i]; } memset(dp,-1,sizeof dp); ll ans=1e10; for(int i=a; i<=b; i++) { ans=min(ans,solve(1,i)); } cout<<ans<<endl; 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...