Submission #610522

#TimeUsernameProblemLanguageResultExecution timeMemory
610522nohaxjustsofloBali Sculptures (APIO15_sculpture)C++17
0 / 100
1044 ms15996 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set; mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count()); //uniform_int_distribution<int> gen; ///(min, max) //int random() {return gen(mt_rand);} const int mxN=2001; const int mod=998244353; const int mxlogN=40; const int mxK=26; const ll inf=1e18; const int K=600; int dp[mxN][mxN], a[mxN]; ll check(int i, int k, ll msk, int n) { if(i==n) return k==0; if(!k) return 0; if(~dp[i][k]) return dp[i][k]; ll sum=0; for(int j=i+1; j<=n; j++) { sum+=a[j-1]; if((msk&sum)==sum) if(check(j,k-1,msk,n)) return dp[i][k]=1; } return dp[i][k]=0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); for(int i=0; i<mxN; i++) for(int j=0; j<mxN; j++) dp[i][j]=-1; int n,A,B; cin >> n >> A >> B; for(int i=0; i<n; i++) cin >> a[i]; ll ans=inf; for(int k=A; k<=B; k++) { ll msk=(1LL<<(mxlogN+1))-1; for(int j=0; j<=mxlogN; j++) { msk^=check(0,k,msk^1LL<<(mxlogN-j),n)<<(mxlogN-j); for(int i=0; i<mxN; i++) for(int j=0; j<mxN; j++) dp[i][j]=-1; } ans=min(ans,msk); } cout << ans << "\n"; } /* 6 2 2 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...