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);
vector<int> vec;
long long sum = 0;
for (int i = 0; i < k - 1; i++)
{
x[i] = skim(i + 1);
sum += x[i];
vec.push_back(i + 1);
}
int l = k - 1, r = n;
while (l != r)
{
int m = (l + r) >> 1;
if (x[m] == 0) x[m] = skim(m + 1);
if (x[m] <= a) l = m + 1;
else r = m;
}
assert(r == n || x[r] > a);
if (r < n)
{
sum += x[r];
vec.push_back(r + 1);
if (a <= sum && sum <= a * 2) answer(vec);
}
vector<long long> nums;
for (int i = 0; i < k; i++)
{
if (x[i] == 0) x[i] = skim(i + 1);
nums.push_back(i + 1);
}
for (int i = max(k, r - k); i < r; i++)
{
if (x[i] == 0) x[i] = skim(i + 1);
nums.push_back(i + 1);
}
for (int i = 0; i + k - 1 < (int)(nums.size()); i++)
{
sum = 0;
vec.clear();
for (int j = i; j <= i + k - 1; j++)
{
sum += x[nums[j]];
vec.push_back(nums[j] + 1);
}
if (a <= sum && sum <= a * 2) answer(vec);
}
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... |