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;
//
// --- 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.
//
long long _skim(int i){
return skim(i + 1);
}
void _answer(vector<int> v){
for(auto& i : v) i++;
answer(v);
}
void solve(int N, int K, long long A, int S) {
vector<long long> a(K);
for(int i = 0; i < K; i++){
a[i] = _skim(i);
}
long long s = accumulate(a.begin(), a.end(), 0LL);
if(s > A * 2) impossible();
if(A <= s && s <= A * 2){
vector<int> v; for(int i = 0; i < K; i++) v.push_back(i);
_answer(v);
}
long long upper = A * 2; for(int i = 0; i < K - 1; i++) upper -= a[i];
int lo = K - 1, hi = N - 1;
while(lo != hi){
int mid = (lo + hi + 1) / 2;
long long val = _skim(mid);
if(val <= upper){
lo = mid;
}else{
hi = mid - 1;
}
}
for(int i = 0; i < K; i++){
a[K - 1 - i] = _skim(lo - i);
long long s = accumulate(a.begin(), a.end(), 0LL);
if(s > A * 2) impossible();
if(A <= s && s <= A * 2){
vector<int> v;
for(int j = 0; j < K - i - 1; j++) v.push_back(j);
for(int j = K - i - 1; j < K; j++) v.push_back(lo - (K - 1 - j));
_answer(v);
}
}
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... |