# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
933434 | AtabayRajabli | A Difficult(y) Choice (BOI21_books) | C++17 | 1 ms | 344 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;
const int sz = 1e5 + 5;
int q[sz];
int get(int x)
{
if(q[x])return q[x];
return q[x] = skim(x);
}
void solve(int n, int k, long long a, int s)
{
int l = 1, r = n, ind;
while(l <= r)
{
int m = (l + r) >> 1;
if(get(m) >= a)r = m - 1, ind = m;
else l = m + 1;
}
if(ind < k)impossible();
vector<int> v;
long long sum = 0;
for(int i = 1; i <= k; i++)
{
v.push_back(i);
sum += get(i);
}
if(sum > 2 * a)impossible();
for(int i = max(k + 1, ind - k + 1); i <= ind; i++)
{
v.push_back(i);
}
l = 0, r = k - 1;
for(int i = 0; i + k < v.size(); i++)
{
if(a <= sum && sum <= a * 2)break;
sum -= get(v[l++]);
sum += get(v[r++]);
}
vector<int> ans;
while(l <= r)ans.push_back(v[l++]);
answer(ans);
}
Compilation message (stderr)
# | 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... |