제출 #839342

#제출 시각아이디문제언어결과실행 시간메모리
839342popovicirobertBali Sculptures (APIO15_sculpture)C++14
0 / 100
1 ms260 KiB
#include <bits/stdc++.h> using namespace std; int main() { #ifdef HOME ifstream cin("input.in"); ofstream cout("output.out"); #endif ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int n, A, B; cin >> n >> A >> B; vector<int> x(n + 1); for (int i = 1; i <= n; i++) { cin >> x[i]; } long long answer = 0; if (n <= 100) { for (int bit = 40; bit >= 0; bit--) { vector<vector<bool>> dp(B + 1, vector<bool>(n + 1)); dp[0][0] = true; for (int i = 1; i <= B; i++) { for (int j = 1; j <= n; j++) { long long sum = 0; for (int k = j - 1; k >= 0; k--) { sum += x[k + 1]; if ((sum >> bit) == (answer >> bit)) { dp[i][j] = (dp[i][j] | dp[i - 1][k]); } } } } bool good = false; for (int i = A; i <= B; i++) { good |= dp[i][n]; } if (!good) { answer += (1LL << bit); } } } else { for (int bit = 40; bit >= 0; bit--) { vector<bool> dp(n + 1); dp[0] = true; for (int j = 1; j <= n; j++) { long long sum = 0; for (int k = j - 1; k >= 0; k--) { sum += x[k + 1]; if ((sum >> bit) == (answer >> bit)) { dp[j] = (dp[j] | dp[k]); } } } if (dp[n] == false) { answer += (1LL << bit); } } } cout << answer; 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...