# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96502 | Smelskiy | Bali Sculptures (APIO15_sculpture) | C++14 | 117 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>
using namespace std;
int n;
long long d[2005];
int a, b;
bool can(long long mask) {
int dp[2005];
for (int i = 0; i <= n; i++) {
dp[i] = 100000;
}
dp[0] = 0;
for (int i = 0; i < n; i++) {
if (dp[i] < 100000) {
long long cur_sum = 0;
for (int j = i; j < n; j++) {
cur_sum += d[j];
if ((cur_sum & mask) == 0) {
dp[j+1] = min(dp[j+1], dp[i] + 1);
}
}
}
}
return dp[n] <= b;
}
int main() {
// freopen("sculpture.in", "r", stdin);
// freopen("sculpture.out", "w", stdout);
scanf("%d %d %d", &n, &a, &b);
for (int i = 0; i < n; i++) {
scanf("%lld", &d[i]);
}
long long cur_mask = 0;
for (int i = 60; i >= 0; --i) {
if (can(cur_mask | (1LL<<i))) {
cur_mask = cur_mask | (1LL<<i);
}
}
printf("%lld\n", (1LL<<61) -1 - cur_mask);
}
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... |