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;
const int sz = 1e5 + 5;
long long q[sz];
long long get(long long x)
{
if(q[x])return q[x];
return q[x] = skim(x);
}
void solve(int n, int k, long long a, int s)
{
long long sum = 0;
vector<int> v;
for(int i = 1; i <= k; i++)
{
sum += get(i);
v.push_back(i);
}
if(sum > 2 * a)impossible();
if(a <= sum)answer(v);
long long mx = 2 * a - (sum - get(k));
int l = k + 1, r = n, j = n + 1;
while(l <= r)
{
int m = (l + r) >> 1;
if(get(m) <= mx)l = m + 1, j = m;
else r = m - 1;
}
if(j == n + 1)impossible();
if(sum - get(k) + get(j) >= a)
{
v.pop_back();
v.push_back(j);
answer(v);
}
r = j;
set<int> cur;
for(int i = 1; i <= k; i++)cur.insert(i);
for(int i = 1; r > k; i++)
{
sum -= get(i);
cur.erase(i);
sum += get(r);
cur.insert(r);
r--;
if(a <= sum)
{
vector<int> ans;
for(int i : cur)ans.push_back(i);
answer(ans);
}
}
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... |