Submission #412663

#TimeUsernameProblemLanguageResultExecution timeMemory
412663cfalasA Difficult(y) Choice (BOI21_books)C++14
0 / 100
1 ms304 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;
	while(l<=r){
		//cout<<MID<<" "<<s+q(MID)<<endl;
		if(q(MID)>A) maxa = MID, r=MID-1;
		else l = MID+1;
	}
	FORi(x, 1, K+2){
		ll s=0;
		int cnt=0;
		vector<int> ans;
		FORi(i,x,K+1) s+= q(i), cnt++, ans.push_back(i);
		int j = maxa - K;
		while(cnt<K){
			cnt++;
			ans.push_back(j);
			s+= q(j++);
		}
		//cout<<x<<" "<<s<<endl;
		//FOA(v,ans) cout<<v<<" ";
		//cout<<endl<<endl;
		if(A<=s && s<=2*A){
			answer(ans);
		}
		else if(s<A) l = MID+1;
		else r = MID-1;
	}
	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...