# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
757418 | Trisanu_Das | Bali Sculptures (APIO15_sculpture) | C++17 | 0 ms | 0 KiB |
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 int long long
using namespace std;
signed main() {
int n, s, e; cin >> n >> s >> e;
int a[n + 1];
for(int i = 1; i < n + 1; i++) cin >> a[i];
int ans = (1LL << 41) - 1;
int l[n + 1], R[n + 1];
l[0] = r[0] = 0;
for(int k = 40; k > -1; k--) {
ans ^= 1LL << k;
for(int i = 1; i <= n; i++) {
L[i] = INT_MAX, r[i] = INT_MIN;
int s = 0;
for(int j = i-1; j > -1; j--) {
s += a[j + 1];
if((s & ans) == s) {
l[i] = min(l[i], l[j] + 1);
r[i] = max(r[i], r[j] + 1);
}
}
}
if(!(s <= r[n] && l[n] <= e)) ans ^= 1LL << k;
}
cout << ans << '\n';
}