# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
748013 | vjudge1 | A Difficult(y) Choice (BOI21_books) | C++17 | 1 ms | 336 KiB |
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;
long long n,k,a,s;
void solve(int N, int K, long long A, int S) {
n=N;
k=K;
a=A;
s=S;
vector<long long>all;
vector<int>res;
long long sum=0;
for(int i=1;i<=k;i++){
all.push_back(skim(i));
sum+=all.back();
res.push_back(i);
}
if(sum>2*a){
impossible();
}
if(sum>=a){
answer(res);
}
int low=0,high=n+1,mid;
while(high-low>1){
mid=(high+low)>>1;
if(skim(mid)>=a){
high=mid;
}
else{
low=mid;
}
}
long long fake=0;
if(high!=n+1){
sum-=all.back();
fake=skim(high);
sum+=fake;
if(sum>=a&&sum<=2*a){
res.pop_back();
res.push_back(high);
answer(res);
}
sum-=fake;
sum+=all.back();
}
vector<long long>all2,res2;
long long sum2=0;
for(int i=max(low-k+1,1ll);i<=low;i++){
all2.push_back(skim(i));
res2.push_back(low);
sum2+=all2.back();
}
if(sum2<a){
impossible();
}
while(sum<a)
{
sum-=all.back();
all.pop_back();
sum+=all2.back();
all2.pop_back();
res.pop_back();
}
int now=low;
while((int)res.size()<k){
res.push_back(low);
res2.push_back(low);
low--;
}
answer(res);
}
Compilation message (stderr)
# | 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... |