# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
714872 | stevancv | A Difficult(y) Choice (BOI21_books) | C++14 | 2 ms | 336 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>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const int inf = 1e9;
ll val[N];
void solve(int n, int k, ll a, int s) {
int l = 1, r = n, idx = r + 1;
ll x = -1, y = 0;
while (l <= r) {
int mid = l + r >> 1;
x = skim(mid);
if (x >= a) {
idx = mid;
r = mid - 1;
y = x;
}
else l = mid + 1;
}
if (idx < k) impossible();
for (int i = 1; i <= k; i++) val[i] = skim(i);
if (idx <= n) {
for (int i = 1; i <= k - 1; i++) y += val[i];
if (a <= y && y <= a + a) {
vector<int> v;
for (int i = 1; i <= k - 1; i++) v.push_back(i);
v.push_back(idx);
answer(v);
}
}
x = 0;
for (int i = 1; i <= k; i++) x += val[i];
if (a <= x && x <= a + a) {
vector<int> v(k);
iota(v.begin(), v.end(), 1);
answer(v);
}
l = 1;
r = idx - 1;
while (r >= max(k, idx - k)) {
ll o = skim(r);
x += o - val[l++];
if (a <= x && x <= a + a) {
vector<int> v;
for (int i = l; i <= k; i++) v.push_back(i);
for (int i = r; i <= idx - 1; i++) v.push_back(i);
answer(v);
}
else r--;
}
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... |