# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112120 | toonewbie | Bali Sculptures (APIO15_sculpture) | C++17 | 1051 ms | 16376 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;
#define ll long long
#define F first
#define S second
const int N = 2006;
const int INF = 1e9;
const ll INFLL = 1e18;
int n, a, b;
int y[N];
ll p[N];
int dp[N][N];
int main() {
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> a >> b;
for (int i = 1; i <= n; i++) {
cin >> y[i];
p[i] = p[i - 1] + y[i];
}
ll res = 0;
for (int bt = 42; bt >= 0; bt--) {
ll cur = (1LL << bt) | res;
memset(dp, 0, sizeof(dp));
for (int i = 1; i <= n; i++) {
if ((p[i] & cur) == 0) {
dp[1][i] = 1;
}
}
for (int j = 2; j <= n; j++) {
for (int i = j; i <= n; i++) {
for (int k = j - 1; k < i; k++) {
ll last = p[i] - p[k];
if (dp[j - 1][k] == 1 && ((last & cur) == 0)) {
dp[j][i] = 1;
break;
}
}
}
}
int ok = 1;
for (int i = a; i <= b; i++) {
if (dp[i][n]) {
res |= (1LL << bt);
break;
}
}
}
cout << (1LL << 43) - 1 - res << endl;
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... |