Submission #391056

#TimeUsernameProblemLanguageResultExecution timeMemory
391056BlagojceBali Sculptures (APIO15_sculpture)C++11
100 / 100
587 ms836 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) using namespace std; typedef long long ll; const int mxn = 2e3+5; int N, A, B; int a[mxn]; bitset<mxn> dp[mxn]; bool ok(ll mask){ fr(i, 0, N+1) dp[i] = 0; dp[0][0] = 1; fr(i, 1, N+1){ ll sum = 0; for(int j = i; j >= 1; j --){ sum += a[j-1]; if((mask&sum) == sum){ dp[i] |= (dp[j-1]<<1); } } } bool r = false; fr(i, A, B+1){ r |= dp[N][i]; } return r; } void solve(){ cin >> N >> A >> B; fr(i, 0, N){ cin >> a[i]; } ll mask = (1LL<<41)-1; for(int i = 40; i >= 0; i --){ mask ^= (1LL<<i); if(!ok(mask)){ mask ^= (1LL<<i); } } cout<<mask<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }
#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...