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;
void solve(int n, int k, long long a, int s) {
vector<long long> x(n + 1);
for (int i = 1; i <= n; ++i) x[i] = skim(i);
vector<bool> mk(n + 1);
auto done = [&]() {
vector<int> ret;
for (int i = 1; i <= n; ++i) if (mk[i]) ret.push_back(i);
answer(ret);
exit(0);
};
long long total = 0;
int cnt = 0;
int it = n;
do {
for (int i = it; i >= 1; --i) {
if (mk[i]) continue;
if (total + x[i] <= 2 * a) {
total += x[i];
mk[i] = true;
cnt += 1;
}
if (a <= total && cnt == k) done();
}
for (int i = it; i >= 1; --i) {
if (mk[i]) {
total -= x[i];
mk[i] = false;
cnt -= 1;
it = i - 1;
break;
}
}
} while (true);
impossible();
}
# | 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... |