#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
#define int long long
#define endl '\n'
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define fi first
#define se second
#define pii pair<ll, ll>
#define inf 1e18
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MP make_pair
#define TASK "ghuy4g"
#define start if(fopen(TASK".inp","r")){freopen(TASK".inp","r",stdin);freopen(TASK".out","w",stdout);}
#define LOG 46
#define N 2005
using namespace std;
ll onbit(ll mask, ll i) {
return mask | (1LL << i);
}
ll getbit(ll mask, ll i) {
return (mask >> i) & 1LL;
}
ll gb(ll mask1, ll mask2, ll i) {
return (mask1 >> i) | (mask2 >> i);
}
ll n, L, R;
ll a[N], pf[N];
ll ans;
bitset<N> dp[N];
signed main(void) {
faster;
cin >> n >> L >> R;
for (int i = 1; i <= n; i++) {
cin >> a[i];
pf[i] = pf[i - 1] + a[i];
}
for (int bit = LOG; bit >= 0; bit--) {
for (int k = 0; k <= R; k++) {
dp[k].reset();
}
dp[0][0] = 1;
bool ok = false;
for (int k = 1; k <= R; k++) {
for (int i = 1; i <= n; i ++) {
for (int j = dp[k - 1]._Find_first(); j < i; j = dp[k - 1]._Find_next(j)) {
ll xet = pf[i] - pf[j];
if (gb(xet, ans, bit) == (ans >> bit)) {
dp[k].set(i);
if (k >= L && i == n) {
ok = true;
}
break;
}
if (ok) break;
}
if (ok) break;
}
if (ok) break;
}
if (!ok) {
ans = onbit(ans, bit);
}
}
cout << ans;
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... |