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.
//
typedef long long ll ;
#define vll vector<ll>
#define vi vector<int>
void solve(int n, int k, long long A, int S) {
vll v(n+5,0);
vi r={};
ll s=0;
/*
for(int i=1;i<=k;i++){
r.push_back(i);
v[i]=skim(i);s+=v[i];
if(s>2*A){
impossible();
return;
}
}
ll last=n+1;
for(int i=k;i>0;i--){
s-=v[i];
ll p=i,f=last;
while(abs(p-f)!=1){
ll md=(p+f)/2;
if(v[md]==0)v[md]=skim(md);
if(s+v[md]<A)p=md;
else if(s+v[md]>2*A)f=md;
else{
r[i-1]=md;
answer(r);
return;
}
}for(auto x : r)cout<<x<<" ";cout<<"\n";
r[i-1]=p;
s+=v[p];
last=p;
}
impossible();
//*/
for(int i=1;i<=n;i++){
v[i]=skim(i);
if(i<=k){
s+=v[i];
r.push_back(i);
}
}
if(s>2+A)impossible();
r.push_back(n+1);
for(int i=k;i>0;i--){
s-=v[i];
for(int j=i;j<r[i];j++){
if(s+v[j]>2*A)break;
r[i-1]=j;
}
s+=v[r[i-1]];
if(s+v[r[i-1]]>2*A)break;
}
r.pop_back();
if(s>=A)answer(r);
else 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... |