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<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
const int N = 101, LG = 30;
int n, L, R;
int a[N];
bool dp[N][N];
bool check(int ban) {
memset(dp, 0, sizeof dp);
dp[0][0] = 1;
for (int i = 1; i <= n; ++i) {
int sum = 0;
for (int j = i; j >= 1; --j) {
sum += a[j];
if ((sum & ban) == 0) {
for (int k = 1; k <= n; ++k) {
dp[i][k] |= dp[j - 1][k - 1];
}
}
}
}
for (int i = L; i <= R; ++i) if (dp[n][i]) return 1;
return 0;
}
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
#else
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
cin >> n >> L >> R;
for (int i = 1; i <= n; ++i) cin >> a[i];
int ban = 0;
for (int b = LG - 1; b >= 0; --b) if (check(ban + (1 << b))) ban += 1 << b;
cout << (1 << 30) - 1 - ban << '\n';
}
# | 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... |