# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
849569 | iee | A Difficult(y) Choice (BOI21_books) | C++17 | 1 ms | 1488 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>
#include "books.h"
using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
// books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ books_sample.cpp sample_grader.cpp
// in this folder.
//
void solve(int N, int K, long long A, int S) {
vector<int> av;
for (int i = 1; i <= N; i++) {
av.push_back(i);
}
vector<long long> mem(N + 1, -1);
auto query = [&](int x) {
if (mem[x] != -1) return mem[x];
return mem[x] = skim(x);
};
vector<int> v;
long long cursum = 0;
while (av.size()) {
if (cursum >= A && cursum < A * 2) answer(v);
if (v.size() == S) {
impossible();
}
int i = av.size(), j = 0, keep = 1;
while (i >= 0 && j >= 0) {
if (i >= (1 << j) && query(av[i - (1 << j)]) > A * 2 - cursum) {
i -= (1 << j);
} else {
keep = -1;
}
j += keep;
}
av.resize(i);
if (av.empty()) impossible();
v.push_back(av.back());
cursum += query(av.back());
av.pop_back();
if (cursum >= A && cursum < A * 2) answer(v);
}
impossible();
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |