Submission #452104

#TimeUsernameProblemLanguageResultExecution timeMemory
452104fadi57Bali Sculptures (APIO15_sculpture)C++14
71 / 100
24 ms588 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; const int mx=2004; typedef long long ll; const int mod=1e9+7; const int MXm=22; #define F first #define S second const int inf=1e9+10; ll y[mx],pref[mx]; int n,a,b; ll mask; int dp[200][100]; int solve(){ memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ ll sum=0; for(int k=i;k>=1;k--){ sum+=y[k]; dp[i][j]|=(dp[k-1][j-1]&((sum&mask)==0)); } } } int ok=0; for(int i=a;i<=b;i++){ ok|=dp[n][i]; } return ok; } int main(){ cin>>n>>a>>b; vector<int>v; for(int i=1;i<=n;i++){ cin>>y[i]; } pref[0]=y[0]; for(int i=1;i<n;i++){ pref[i]=y[i]+pref[i-1]; } ll ans=0; ll forbiden=0; for(int i=44;i>=0;i--){ mask|=(1ll<<i); if(solve()){ }else{ ans+=(1LL<<i); mask^=(1LL<<i); } } cout<<ans; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:61:9: warning: unused variable 'forbiden' [-Wunused-variable]
   61 |      ll forbiden=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...