Submission #239604

#TimeUsernameProblemLanguageResultExecution timeMemory
239604michaoBali Sculptures (APIO15_sculpture)C++14
100 / 100
711 ms1060 KiB
#include <bits/stdc++.h> #define ll long long int #define mp make_pair #define pb push_back #define ld long double #define pii pair<int,int> #define sz(x) (int)x.size() #define piii pair<pii,pii> #define precise cout<<fixed<<setprecision(10) #define st first #define nd second #define ins insert #define vi vector<int> #define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) using namespace std; const int MAX=2005; int tab[MAX]; int32_t main() { BOOST; int n,a,b; cin>>n>>a>>b; for (int i=0;i<n;i++)cin>>tab[i]; ll ans=0; for (int i=40;i>=0;i--) { vector<bitset<MAX>>dp(n+1); dp[0]=1; for (int j=1;j<=n;j++) { ll akt=0; for (int k=j-1;k>=0;k--) { akt+=tab[k]; if (!(akt&(1LL<<i)) && ((ans|(akt>>(i+1)))==ans))dp[j]|=(dp[k]<<1); } } bool t=false; for (int j=a;j<=b;j++) if (dp[n][j]){t=true;break;} ans*=2; if (!t)ans++; } cout<<ans; 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...