# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726855 | finn__ | A Difficult(y) Choice (BOI21_books) | C++17 | 2 ms | 420 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;
constexpr size_t N = 100001;
long long cache[N];
long long query(int i) { return cache[i] ? cache[i] : cache[i] = skim(i); }
void solve(int N, int K, long long A, int S)
{
int a = 1, b = N;
while (a < b)
{
int mid = (a + b) / 2;
if (query(mid) <= A)
a = mid + 1;
else
b = mid;
}
long long sum = 0;
for (size_t i = 1; i < K; ++i)
sum += query(i);
if (query(a) <= A)
++a;
if (a <= N && query(a) + sum <= 2 * A)
{
vector<int> v(K);
iota(v.begin(), v.begin() + K - 1, 1);
v.back() = a;
answer(v);
}
sum += query(K);
if (A <= sum && sum <= 2 * A)
{
vector<int> v(K);
iota(v.begin(), v.end(), 1);
answer(v);
}
if (2 * K >= a)
{
for (size_t i = K + 1; i < a; ++i)
{
sum -= query(i - K);
sum += query(i);
if (A <= sum && sum <= 2 * A)
{
vector<int> v;
iota(v.begin(), v.end(), i - K + 1);
answer(v);
}
}
}
else
{
for (size_t i = 0; i < K; ++i)
{
sum -= query(K - i);
sum += query(a - K + i);
if (A <= sum && sum <= 2 * A)
{
vector<int> v(K);
iota(v.begin(), v.begin() + K - i - 1, 1);
iota(v.begin() + K - i - 1, v.end(), a - K);
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... |