# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
531918 | 4fecta | A Difficult(y) Choice (BOI21_books) | C++17 | 0 ms | 0 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;
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)
int h[100005], in[100005];
void solve(int n, int k, int a, int s) {
vector<int> ret;
int sum = 0;
for (int i = 1; i < k; i++) {
h[i] = skim(i);
sum += h[i];
in[i] = 1;
}
int lo = k, hi = n, mid;
while (lo < hi) {
mid = (lo + hi + 1) >> 1;
h[mid] = skim(mid);
if (sum + h[mid] > 2 * a) hi = mid - 1;
else lo = mid;
}
in[lo] = 1;
if (sum + h[lo] >= a) {
for (int i = 0; i < 100005; i++) if (in[i]) ret.push_back(i);
answer(ret);
}
for (int i = 1; i < k; i++) {
h[lo - i] = skim(lo - i);
sum += h[lo - i] - h[k - i];
in[lo - i] = 1, in[k - i] = 0;
if (sum + h[lo] >= a) {
for (int i = 0; i < 100005; i++) if (in[i]) ret.push_back(i);
answer(ret);
}
}
impossible();
}
int32_t main() {
boost();
return 0;
}