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"
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define EB emplace_back
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int n;
ll a, BIO[N];
ll _skim(int x) {
if(x <= 0 || x > n) return 0;
if(BIO[x]) return BIO[x];
return BIO[x] = skim(x);
}
void _answer(ll sum, int l, int r, int _l, int _r) {
if(sum < a || sum > 2 * a) return;
vector<int> ANS;
for(int i = l; i < r; ++i) ANS.EB(i);
for(int i = _l; i < _r; ++i) ANS.EB(i);
answer(ANS);
}
void solve(int _n, int k, ll _a, int s) {
n = _n;
a = _a;
int lo = 0, hi = n + 1;
while(hi - lo > 1) {
int mi = (lo + hi) / 2;
if(_skim(mi) < a) lo = mi;
else hi = mi;
}
if(n < k || hi < k) impossible();
for(int i = 1; i <= k; ++i) _skim(i);
for(int i = 0; i < k; ++i) _skim(lo - i);
ll sum = 0;
for(int i = lo - k + 1; i <= lo; ++i) sum += _skim(i);
if(lo >= k) {
_answer(sum, 0, 0, lo - k + 1, lo + 1);
for(int i = lo - k + 1, j = 1; i <= lo; ++i, ++j) {
sum += _skim(j) - _skim(i);
_answer(sum, 1, j + 1, i + 1, lo + 1);
}
}
if(hi <= n) {
sum = _skim(hi);
for(int i = 1; i < k; ++i) sum += _skim(i);
_answer(sum, 1, k, hi, hi + 1);
}
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... |