이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int bits = 45;
const int MXN = 2001;
const int INF = 1e9;
int64_t pref[MXN];
int A, B, N;
bool check(int64_t mask){
vector<int> dp(N+1, INF);
dp[0] = 0;
for(int i = 1; i <= N; i++){
for(int j = 0; j < i; ++j){
if((mask | (pref[i] - pref[j])) != mask) continue;
dp[i] = min(dp[i], dp[j] + 1);
}
}
return dp[N] <= B;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N >> A >> B;
for(int i = 1; i <= N; i++){
cin >> pref[i];
pref[i] += pref[i-1];
}
int64_t ans = (1LL << bits) - 1;
for(int bit = bits - 1; bit >= 0; --bit){
int64_t red = (1LL << bit);
if(check(ans - red)) ans -= red;
}
cout << ans << '\n';
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... |