제출 #48150

#제출 시각아이디문제언어결과실행 시간메모리
48150E869120Bali Sculptures (APIO15_sculpture)C++14
37 / 100
8 ms1092 KiB
#include <iostream> using namespace std; int N, A, B, X[2009], dp[2009][2009], bit[30]; bool solve() { int P = 0; for (int i = 0; i < 30; i++) P += bit[i] * (1LL << i); for (int i = 0; i <= N + 1; i++) { for (int j = 0; j <= B; j++) dp[i][j] = 0; } dp[1][0] = 1; for (int i = 1; i <= N; i++) { for (int j = 0; j <= B; j++) { if (dp[i][j] == 0) continue; long long s = 0; for (int k = i + 1; k <= N + 1; k++) { s += X[k - 1]; if (s > P) break; if ((s | P) == P) { dp[k][j + 1] = 1; } } } } for (int i = A; i <= B; i++) { if (dp[N + 1][i] == 1) return true; } return false; } int main() { cin >> N >> A >> B; for (int i = 1; i <= N; i++) cin >> X[i]; for (int i = 0; i < 30; i++) bit[i] = 1; for (int i = 29; i >= 0; i--) { bit[i] = 0; bool OK = solve(); if (OK == false) bit[i] = 1; } int ret = 0; for (int i = 0; i < 30; i++) ret += bit[i] * (1LL << i); cout << ret << 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...