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
void solve(int N, int K, long long A, int S) {
// TODO implement this function
int l=0,r=N,m;
while (l!=r-1){
m=(l+r)>>1;
if (skim(m)>2*A/K) r=m;
else l=m;
} //r is first impossible guy
if (r==1){
impossible();
return;
}
ll arr[N+5];
ll s=max(1,r-K),e=min(N,r+K-1);
for (int i=s;i<=e;i++){
arr[i]=skim(i);
}
if (e-s+1<K){
impossible();
return;
}
vector<int> v;
for (int i=s;i<=e-K+1;i++){
ll tot=0;
for (int j=i;j<=i+K-1;j++){
v.emplace_back(j);
tot+=arr[j];
}
//cerr<<endl<<i<<' '<<i+K-1<<' '<<tot<<endl;
if (tot>=A && tot<=2*A){
answer(v);
return;
}
v.clear();
}
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... |