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>
// #pragma GCC optimize ("O2,unroll-loops")
// #pragma GCC optimize("no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios::sync_with_stdio(0), cin.tie(), cout.tie();
#define fr first
#define sc second
#define all(v) v.begin(), v.end()
#define uni(v) sort(all(v)), v.erase(unique(all(v)), v.end())
// #define c0 (v << 1)
// #define c1 (c0 | 1)
// #define md ((l+r)>>1)
using namespace std;
typedef long long ll;
const int maxN = 1e2+7;
ll pef[maxN];
int y[maxN];
bitset<maxN> dp[maxN];
inline ll range(int l, int r){
return pef[r+1]-pef[l];
}
signed main(){IOS
int n;
int a, b;
cin >> n >> a >> b;
for(int i = 0; i < n; i++){
cin >> y[i];
}
assert(n < maxN);
ll ans = 0;
ll bads = 0;
pef[0] = 0;
for(int i = 0; i < n; i++)pef[i+1] = pef[i]+y[i];
ll maxAns = 1ll << 40;
for(int bit = 40; bit >= 0; bit--){
bads += (1ll << bit);
for(int i = 0; i <= n; i++)for(int j = 0; j <= n; j++)dp[i][j] = 0;
for(int i = a; i <= b; i++)dp[0][i] = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j <= i; j++){
if(range(j, i) < maxAns && (range(j, i) & bads) == 0){
dp[i+1] |= dp[j] >> 1;
}
}
}
if(dp[n][0] == 0){
bads ^= (1ll << bit);
ans ^= (1ll << bit);
}
}
cout << ans << '\n';
}
/*
6 1 3
8 1 2 1 5 4
*/
# | 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... |