제출 #412684

#제출 시각아이디문제언어결과실행 시간메모리
412684cfalasA Difficult(y) Choice (BOI21_books)C++14
100 / 100
3 ms328 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...