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>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID ((l+r)/2)
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;
#define EPS 1e-6
#define FOR(i,n) for(int i=0;i<((int)(n));i++)
#define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define FOA(v, a) for(auto v : a)
#include "books.h"
using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
// books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ books_sample.cpp sample_grader.cpp
// in this folder.
//
ll a[10000000];
ll q(int x){
if(a[x]) return a[x];
a[x] = skim(x);
return a[x];
}
void solve(int n, int K, long long A, int S) {
// cons
int l=K, r=n;
int maxa=n+1;
ll s=0;
FOR(i,K) s+=q(i+1);
while(l<=r){
if(s-q(K) + q(MID)<=2*A) maxa = MID, l=MID+1;
else r = MID-1;
}
if(s>2*A) impossible();
if(s>=A){
vector<int> ans;
FORi(i,1,K+1) ans.push_back(i);
answer(ans);
}
int ind=K;
FORi(x, 0, K){
s-=q(ind--);
s+=q(maxa-x);
//cout<<x<<" "<<s<<endl;
if(A<=s && s<=2*A){
vector<int> ans;
FORi(i,maxa-x,maxa+1) ans.push_back(i);
FORi(i,1,ind+1) 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... |