Submission #1076016

#TimeUsernameProblemLanguageResultExecution timeMemory
1076016alexddBali Sculptures (APIO15_sculpture)C++17
37 / 100
16 ms612 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int n,a,b; int y[2005],sump[2005]; bool verif_normal(int lim) { vector<vector<bool>> dp(n+2,vector<bool>(n+2,0)); dp[0][0]=1; for(int i=1;i<=n;i++) { for(int cnt=1;cnt<=n;cnt++) { dp[i][cnt]=0; for(int j=0;j<i;j++) { int s = sump[i]-sump[j]; if(dp[j][cnt-1] && (lim|s)==lim) dp[i][cnt]=1; } } } for(int i=a;i<=b;i++) if(dp[n][i]) return 1; return 0; } /** dp[i][cnt] = 0/1 dp[i][cnt] |= dp[x][cnt-1], daca */ bool verif(int lim) { return verif_normal(lim); } signed main() { cin>>n>>a>>b; for(int i=1;i<=n;i++) { cin>>y[i]; sump[i] = sump[i-1]+y[i]; } int pref=(1<<30)-1; for(int b=29;b>=0;b--) { pref -= (1<<b); if(!verif(pref)) pref += (1<<b); } cout<<pref; return 0; } /** 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...