Submission #388798

#TimeUsernameProblemLanguageResultExecution timeMemory
388798phathnvBali Sculptures (APIO15_sculpture)C++11
71 / 100
56 ms4300 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2007; int n, a, b, x[N]; namespace subtask4{ bool dp[N][N]; bool check(ll val){ memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for(int i = 1; i <= n; i++) for(int j = 1; j <= b; j++){ ll sum = 0; for(int k = i; k >= 1; k--){ sum += x[k]; if ((sum | val) == val) dp[i][j] |= dp[k - 1][j - 1]; } } for(int i = a; i <= b; i++) if (dp[n][i]) return 1; return 0; } void solve(){ ll answer = (1ll << 41) - 1; for(int i = 40; i >= 0; i--){ answer ^= (1ll << i); if (!check(answer)) answer ^= (1ll << i); } cout << answer; } } namespace subtask5{ void solve(){ } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> a >> b; for(int i = 1; i <= n; i++) cin >> x[i]; if (n <= 100) subtask4::solve(); else subtask5::solve(); return 0; } /* 6 1 3 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...