This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
long long N, A, B, L[1 << 12], dp[2009][2009], dp2[2009];
bool solve_1(long long E) {
for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) dp[i][j] = 0; }
dp[0][0] = 1;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (dp[i][j] == 0) continue;
long long R = 0;
for (int k = i + 1; k <= N; k++) {
R += L[k - 1];
if ((R | E) == E) dp[k][j + 1] = 1;
}
}
}
for (int i = A; i <= B; i++) {
if (dp[N][i] == 1) return true;
}
return false;
}
bool solve_2() {
return false;
}
int main() {
cin >> N >> A >> B;
for (int i = 0; i < N; i++) cin >> L[i];
if (N <= 100) {
long long cx = (1LL << 45) - 1;
for (int i = 44; i >= 0; i--) {
bool t = solve_1(cx - (1LL << i));
if (t == true) cx -= (1LL << i);
}
cout << cx << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |