# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
699334 | CatalinT | Bali Sculptures (APIO15_sculpture) | C++17 | 77 ms | 364 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 <vector>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <sstream>
using namespace std;
using int64 = long long;
int N, A, B;
vector<int> X;
int64 S;
bool can_do(int64 mask, int64 care) {
vector<int> dp(N + 1, (1<<30));
dp[0] = 0;
for (int i = 1; i <= N; i++) {
int64 cur = 0;
int64 ored = 0;
for (int j = i; j >= 1; j--) {
cur += X[j];
if (((cur & care) | mask) == mask) {
if (dp[i] > dp[j-1] + 1) {
dp[i] = dp[j-1] + 1;
}
}
}
}
return dp[N] <= B;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N >> A >> B;
X.resize(N + 1);
for (int i = 1; i <= N; i++) {
cin >> X[i];
S += X[i];
}
const int max_bit = 42;
int64 mask = 0;
int64 care = 0;
for (int i = max_bit; i >= 0; i--) {
int64 bit = (1LL<<i);
care |= bit;
if (can_do(mask, care)) {
} else {
mask |= bit;
}
}
cout << mask << "\n";
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... |