# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260098 | pure_mem | Bali Sculptures (APIO15_sculpture) | C++14 | 180 ms | 504 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 ll long long
#define X first
#define Y second
#define MP make_pair
using namespace std;
const int N = 2e3 + 2;
int A, B, n, dp[N];
ll pr[N], ans;
bool sub_mask(ll x, ll y, ll idx){
x >>= idx, y >>= idx;
if((x & y) != y){
return 0;
}
return 1;
}
bool check(ll idx){
//memset(dp, 0, sizeof(dp));
for(int i = 1;i <= n;i++)
dp[i] = n + 2;
dp[0] = 0;
for(int i = 1;i <= n;i++){
for(int j = 0;j < i;j++){
//cerr << ans << " " << pr[i] - pr[j] << "\n";
if(sub_mask(ans, pr[i] - pr[j], idx)){
dp[i] = min(dp[i], dp[j] + 1);
}
}
}
//cerr << dp[n] << "\n";
if(dp[n] < A || dp[n] > B)
return 0;
return 1;
}
int main () {
scanf("%d %d %d", &n, &A, &B);
for(int i = 1, x;i <= n;i++){
scanf("%d", &x), pr[i] = pr[i - 1] + x;
}
for(ll idx = 50;idx >= 0;idx--){
if(!check(idx)){
ans ^= (1ll << idx);
}
}
cout << ans;
}
Compilation message (stderr)
# | 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... |