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 pb push_back
#define ld double
#define ll long long
mt19937 rnd(51);
const int K = 42;
signed main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif // LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, x, y;
cin >> n >> x >> y;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll res = (1LL << K) - 1;
for (int b = K - 1; b >= 0; b--) {
res -= (1LL << b);
vector<vector<bool>> dp(n + 1, vector<bool>(n + 1));
dp[0][0] = 1;
for (int i = 0; i < n; i++) {
ll sum = 0;
for (int j = i; j < n; j++) {
sum += a[j];
if ((sum | res) == res) {
for (int f = 0; f < n; f++) {
if (dp[i][f]) {
dp[j + 1][f + 1] = 1;
}
}
}
}
}
bool good = 0;
for (int i = x; i <= y; i++) {
if (dp[n][i]) {
good = 1;
}
}
if (!good) res += (1LL << b);
}
cout << res << 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... |