Submission #566667

#TimeUsernameProblemLanguageResultExecution timeMemory
566667ac2huBali Sculptures (APIO15_sculpture)C++14
100 / 100
480 ms852 KiB
#include <bits/stdc++.h> #ifdef DEBUG #include "../templates/debug.h" #else #define deb(x...) #endif using namespace std; #define int long long signed main() { iostream::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int n, a, b;cin >> n >> a >> b; vector<int> Y(n); for(auto &e : Y)cin >> e; auto solve = [&](int msk, int down){ bitset<2010> dp[n + 1]; dp[0][0] = true; for(int i = 1;i<=n;i++){ int tsum = 0; for(int j = i;j>=1;j--){ tsum += Y[j - 1]; if((((tsum >> down)|msk) == msk)){ dp[i] |= (dp[j - 1] << 1); } } } // deb(dp[n]); bool ans = 0; for(int i = a;i<=b;i++) ans |= dp[n][i]; return ans; }; int msk = 0, down = 40; while(down >= 0){ msk *= 2; if(!solve(msk, down))msk += 1; down--; } // cout << solve(msk, down); cout << msk << "\n"; }
#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...