# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
467853 | JovanB | A Difficult(y) Choice (BOI21_books) | C++17 | 1 ms | 284 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;
using ll = long long;
void solve(int N, int K, long long A, int S) {
vector <pair <ll, int>> vals;
int l = 1, r = N, gde = 0;
while(l <= r){
int mid = (l+r)/2;
if(skim(mid) <= A/K){
l = mid + 1;
gde = mid;
}
else r = mid - 1;
}
for(int i=max(1, gde-K-1); i<=min(N, gde+K+1); i++) vals.push_back({skim(i), i});
ll sum = 0;
for(int i=0; i<K; i++) sum += vals[i].first;
if(A <= sum && sum <= 2*A){
vector <int> res;
for(int j=0; j<K; j++) res.push_back(vals[j].second);
answer(res);
return;
}
for(int i=K; i<vals.size(); i++){
sum -= vals[i-K].first;
sum += vals[i].first;
if(A <= sum && sum <= 2*A){
vector <int> res;
for(int j=i-K+1; j<=i; j++) res.push_back(vals[j].second);
answer(res);
return;
}
}
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... |