이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |