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>
#define ll long long
using namespace std;
const int N = 2e3 + 5;
int n, u, v;
int a[N];
ll pre[N];
bool ck(ll a, ll b, ll c){
return (a | b) < (b | c);
}
namespace sub1{
int dp[N];
void solve(){
ll ans = 0;
for (ll i = 45; i >= 0; -- i){
ll cur = (1 << i);
for (int j = 1; j <= n; ++ j){
dp[j] = n + 1;
for (int k = j - 1; k >= 0; -- k){
if (ck(pre[j] - pre[k], ans, cur)) dp[j] = min(dp[j], dp[k] + 1);
}
}
if (dp[n] > v) ans += cur;
}
cout << ans;
}
}
namespace sub2{
void solve(){
}
}
void solve(){
cin >> n >> u >> v;
for (int i = 1; i <= n; ++ i) cin >> a[i], pre[i] = pre[i - 1] + a[i];
if (u == 1) sub1::solve();
else sub2::solve();
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
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... |