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;
int n, a, b; long long ans, A[2005];
bool test(long long bad){
int lst[b + 1]; fill(lst, lst + b + 1, -1); lst[0] = 0;
for (int i = 1; i <= n; i++)
for (int j = min(b, i); j >= 1; j--){
if (~lst[j - 1] and !((A[i] - A[lst[j - 1]]) & bad))
lst[j] = i;
if (i == n and j >= a and j <= b and lst[j] == n)
return 1;
}
return 0;
}
int main(){
cin >> n >> a >> b;
for (int i = 1; i <= n; i++)
cin >> A[i], A[i] += A[i - 1];
for (long long i = (1LL << 40), bad = 0; i > 0; i /= 2)
if (!test(bad += i))
bad -= i, ans += i;
cout<<ans<<endl;
}
| # | 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... |