Submission #495554

#TimeUsernameProblemLanguageResultExecution timeMemory
495554FairyWinxBali Sculptures (APIO15_sculpture)C++17
21 / 100
2 ms720 KiB
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define SOLVE int t; cin >> t; while (t--) solve(); #define int long long using namespace std; const int N = 2e3 + 228; int good[N][N]; long long pr[N]; bool check(int n, int R, int ind) { vector<int> dp(n + 1, n + 228); dp[0] = 0; for (int i = 1; i <= n; ++i) { for (int j = 0; j < i; ++j) { if (i == n) { // } if (!good[j][i - 1] && !((pr[i] - pr[j]) & (1 << ind))) { dp[i] = min(dp[i], dp[j] + 1); } } } return dp[n] <= R; } signed main() { #ifdef DEBUG freopen("main/in.txt", "r", stdin); #endif #ifndef LOCAL ios_base::sync_with_stdio(0); cin.tie(0); #endif int n, L, R; cin >> n >> L >> R; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; pr[i + 1] = pr[i] + a[i]; } int ans = 0; for (int i = 30; i >= 0; --i) { if (!check(n, R, i)) { ans += (1 << i); } else { for (int j = 0; j < n; ++j) { for (int k = 0; k <= j; ++k) { if ((pr[j + 1] - pr[k]) & (1 << i)) { good[k][j] = 1; } } } } } cout << ans << '\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...