# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
886802 | anha3k25cvp | Bali Sculptures (APIO15_sculpture) | C++14 | 4 ms | 712 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 ull unsigned long long
#define dl double
#define st first
#define nd second
#define II pair <int, int>
using namespace std;
const int N = 1 + 2e3;
const int inf = 7 + 1e9;
int main() {
#define TASKNAME ""
ios_base :: sync_with_stdio (0);
cin.tie (0);
if ( fopen( TASKNAME".inp", "r" ) ) {
freopen (TASKNAME".inp", "r", stdin);
freopen (TASKNAME".out", "w", stdout);
}
int n, L, R;
cin >> n >> L >> R;
vector <ll> a(n + 1, 0);
for (int i = 1; i <= n; i ++) {
cin >> a[i];
a[i] += a[i - 1];
}
int ans = 0;
vector <int> ok(60, 0);
while (1) {
for (int bit = -1; bit < 60; bit ++) {
vector <bitset <N>> f(n + 1);
f[0][0] = 1;
for (int i = 1; i <= n; i ++)
for (int j = 0; j < i; j ++) {
ll val = a[i] - a[j], check = 1;
for (ll si = val; si > 0; si ^= si & -si) {
int i = __builtin_ctz(si & -si);
if (i > bit && !ok[i]) {
check = 0;
break;
}
}
if (!check)
continue;
f[i] |= f[j] << 1;
}
int check = 0;
for (int i = L; i <= R; i ++)
if (f[n][i]) {
check = 1;
break;
}
if (check) {
if (bit < 0) {
cout << ans;
return 0;
}
ok[bit] = 1;
ans += (ll)1 << bit;
break;
}
}
}
return 0;
}
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... |