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;
void just_do_it();
int main() {
#ifdef KAMIRULEZ
freopen("kamirulez.inp", "r", stdin);
freopen("kamirulez.out", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
just_do_it();
return 0;
}
const int maxN = 2e3 + 20;
int a[maxN];
bool can[maxN][maxN];
void just_do_it() {
int N, A, B;
cin >> N >> A >> B;
for (int i = 1; i <= N; i++) {
cin >> a[i];
}
long long pref = 0;
long long res = 0;
for (int b = 39; b >= 0; b--) {
pref |= (1LL << b);
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= N; j++) {
can[i][j] = false;
}
}
can[0][0] = true;
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
long long S = 0;
for (int k = i; k >= 1; k--) {
S += a[k];
if (((S & pref) | res) == res) {
can[i][j] |= can[k - 1][j - 1];
}
}
}
}
bool ok = false;
for (int j = A; j <= B; j++) {
ok |= can[N][j];
}
if (!ok) {
res |= (1LL << b);
}
}
cout << res;
}
# | 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... |