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.
//
#define ll long long
ll arr[100005];
void solve(int N, int K, long long A, int S) {
// TODO implement this function
ll l=0,r=N+1,m;
while (l!=r-1){
m=(l+r)>>1;
arr[m]=skim(m);
if (arr[m]>=A) r=m;
else l=m;
}
for (int i=1;i<=K;i++) arr[i]=skim(i);
for (int i=max(1LL,r-K);i<=min<ll>(r,N);i++) arr[i]=skim(i);
ll tot=0;
vector<int> out;
if (r!=N+1){
for (int i=1;i<K;i++){
tot+=arr[i];
out.emplace_back(i);
}
tot+=arr[r];
out.emplace_back(r);
if (tot>=A && tot<=2*A){
answer(out);
return;
}
out.clear();
}
ll lptr=K,rptr=0;
while (lptr!=-1){
tot=0;
for (int i=1;i<=lptr;i++){
tot+=arr[i];
out.emplace_back(i);
}
for (int i=r-rptr;i<r;i++){
tot+=arr[i];
out.emplace_back(i);
}
if (tot>=A && tot<=2*A){
answer(out);
return;
}
out.clear();
lptr--,rptr++;
}
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... |