제출 #211642

#제출 시각아이디문제언어결과실행 시간메모리
211642DS007Bali Sculptures (APIO15_sculpture)C++14
0 / 100
5 ms436 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 6; int n, a, b; int y[N], p[N]; void solveTestCase() { cin >> n >> a >> b; for (int i = 0; i < n; i++) cin >> y[i]; p[0] = y[0]; for (int i = 1; i < n; i++) p[i] = y[i] + p[i - 1]; int ans = 0; for (int i = 5; i >= 0; i--) { int dp[n]; fill(dp, dp + n, 1e14); int up = ans + (1ll << i); bool check = y[0] < up; dp[0] = 1; for (int j = 1; j < n; j++) { check = check && y[j] < up; if (p[j] < up && (p[j] | up) < up + (1ll << i) && (p[j] & (1 << i)) == 0) dp[j] = 1; for (int k = j - 1; k >= 0; k--) { if ((p[j] - p[k + 1] + y[k + 1]) < up && ((p[j] - p[k + 1] + y[k + 1]) | up) < up + (1ll << i) && ((p[j] - p[k + 1] + y[k + 1]) & (1 << i)) == 0) dp[j] = min(dp[j], dp[k] + 1); } } if (!check || dp[n - 1] > b) ans = up; } cout << ans; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int test = 1; //cin >> test; while (test--) solveTestCase(); }
#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...