# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863526 | Ahmed_Solyman | A Difficult(y) Choice (BOI21_books) | C++14 | 1 ms | 600 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;
typedef long long ll;
//
// --- 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.
//
void solve(int n, int k, long long a, int s) {
// TODO implement this function
ll sum=0;
vector<int>v;
for(int i=1;i<k;i++)sum+=skim(i),v.push_back(i);
int l=k,r=n;
while(l<=r){
int mid=l+r>>1;
ll s=sum+skim(mid);
if(s<a){
l=mid+1;
}
else if(s>a*2){
r=mid-1;
}
else{
v.push_back(mid);
answer(v);
}
}
l=1;r=n-k+1;
while(l<=r){
int mid=l+r>>1;
ll S=0;
vector<int>v;
for(int i=mid;i<mid+k;i++){
v.push_back(i);
S+=skim(i);
}
if(S<a){
l=mid+1;
}
else if(S>a*2){
r=mid-1;
}
else{
answer(v);
}
}
impossible();
}
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... |