Submission #674600

#TimeUsernameProblemLanguageResultExecution timeMemory
674600parsadox2Bali Sculptures (APIO15_sculpture)C++14
50 / 100
141 ms480 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define debug(x) cout << #x << "= " << x << ", " #define ll long long #define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define Sz(x) (int) x.size() #define int long long using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 2e3 + 10 , maxl = 50; int n , ar[maxn] , a , b , res , ps[maxn]; int dp[maxn]; bool find_ans(int mask) { for(int i = 1 ; i <= n ; i++) dp[i] = n + 1; dp[0] = 0; for(int i = 1 ; i <= n ; i++) { for(int k = 0 ; k < i ; k++) { int tmp = ps[i] - ps[k]; if((tmp & mask) == tmp) dp[i] = min(dp[i] , dp[k] + 1); } } bool flg = false; if(dp[n] <= b) flg = true; return flg; } void solve() { for(int bit = maxl ; bit > -1 ; bit--) { int tmp = res; tmp |= ((1LL << (bit)) - 1); if(!find_ans(tmp)) res |= (1LL << bit); } } int32_t main() { fast; cin >> n >> a >> b; for(int i = 1 ; i <= n ; i++) { cin >> ar[i]; ps[i] = ps[i - 1] + ar[i]; } solve(); cout << res << 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...