# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
933465 | AtabayRajabli | A Difficult(y) Choice (BOI21_books) | C++17 | 1 ms | 600 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;
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)
{
vector<int> v;
__int128 sum = 0;
for(int i = 1; i <= k; i++)
{
v.push_back(i);
sum += get(i);
if(sum > 2 * a)impossible();
}
int l = 1, r = n, ind = n + 1;
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();
for(int i = max(k + 1, ind - k); i < ind; i++)
{
v.push_back(i);
}
l = 0, r = k;
for(int i = 0; r < v.size(); i++)
{
if(a <= sum && sum <= a * 2)break;
sum -= get(v[l]), l++;
sum += get(v[r]), r++;
}
if(a <= sum && sum <= a * 2)
{
vector<int> ans;
while(l < r)ans.push_back(v[l++]);
answer(ans);
}
else impossible();
}
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... |