Submission #131296

#TimeUsernameProblemLanguageResultExecution timeMemory
131296mlyean00Bali Sculptures (APIO15_sculpture)C++14
71 / 100
1067 ms892 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n, a, b; cin >> n >> a >> b; vector<ll> y(n); for (int i = 0; i < n; ++i) { cin >> y[i]; } vector<ll> pref(n + 1, 0); partial_sum(y.begin(), y.end(), pref.begin() + 1); ll ans = 0; for (int bit = 40; bit >= 0; --bit) { bool dp[b + 1][n + 1]; memset(dp, 0, sizeof(dp)); dp[0][0] = true; ll b1 = ans >> bit; bool p = false; for (int i = 0; i < b; ++i) { for (int j = 0; j <= n; ++j) { if (!dp[i][j]) continue; for (int k = j + 1; k <= n; ++k) { ll b2 = (pref[k] - pref[j]) >> bit; dp[i + 1][k] |= (b1 | b2) == b1; } } if (i + 1 >= a && dp[i + 1][n]) p = true; } if (!p) ans |= (1LL << bit); } cout << ans << 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...