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;
typedef long long ll;
int n, a, b;
int v[2020];
void solve1(){
int dp[2020];
ll ans = 0;
for(int i=41; ~i; i--){
memset(dp, 0x3f,sizeof dp);
dp[0] = 0;
for(int j=0; j<=n; j++){
ll now = 0;
for(int k=j+1; k<=n; k++){
now += v[k];
if((now >> i) & 1) continue;
ll ta = now >> (i + 1);
ll tb = ans >> (i + 1);
if(ta & ~tb) continue;
dp[k] = min(dp[k], dp[j] + 1);
}
}
if(dp[n] > b) ans |= (1LL << i);
}
cout << ans;
exit(0);
}
void solve2(){
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> a >> b;
for(int i=1; i<=n; i++) cin >> v[i];
if(a == 1) solve1();
solve2();
}
# | 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... |