# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1031343 | _8_8_ | 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>
using namespace std;
typedef long long ll;
const int N = 2e3 + 21, MOD = (int)1e9+7;
#define int ll
int n,a,b,x[N],dp[N];
void test() {
cin >> n >> a >> b;
for(int i = 1;i <= n;i++) {
cin >> x[i];
}
ll cur = 0,res = 0;
for(ll c = 41;c >= 0;c--){
for(int i = 1;i <= n;i++){
dp[i] = 1e9;
}
cur += (1ll << c);
for(int i = 1;i <= n;i++){
ll s = 0;
for(int j = i;j >= 1;j--){
s += x[j];
if((s & cur) == 0)
{
dp[i] = min(dp[i],dp[j - 1] + 1);
}
}
}
if(dp[n] == (int)1e9){
cur -= (1ll << c);
res += (1ll << c);
}
}
cout << res;
}
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
int t = 1;
// cin >> t;
while(t--) {
test();
}
}