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 "books.h"
using namespace std;
#define N 100000
static long long aa[N + 1];
void solve(int n, int k, long long a, int s) {
vector<int> ii(k);
int i, lower, upper;
long long sum;
lower = 1, upper = n + 1;
while (upper - lower > 1) {
i = (lower + upper) / 2;
if ((aa[i] = skim(i)) >= a)
upper = i;
else
lower = i;
}
if (upper < k) {
impossible();
return;
}
for (i = 1; i <= k; i++)
aa[i] = skim(i);
if (upper <= n) {
sum = aa[upper];
for (i = 1; i < k; i++)
sum += aa[i];
if (sum <= a * 2) {
for (i = 1; i < k; i++)
ii[i - 1] = i;
ii[k - 1] = upper;
answer(ii);
return;
}
if ((n = upper - 1) < k) {
impossible();
return;
}
}
sum = 0;
for (i = 1; i <= k; i++)
ii[i - 1] = i, sum += aa[i];
if (sum >= a && sum <= 2 * a) {
answer(ii);
return;
}
for (i = k; i >= 1; i--) {
ii[i - 1] = n - (k - i), sum += skim(n - (k - i)) - aa[i];
if (sum >= a && sum <= 2 * a) {
answer(ii);
return;
}
}
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... |