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 "books.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
map<int, ll> mp;
ll get(int pos){
if(mp.find(pos) != mp.end()) return mp[pos];
return mp[pos] = skim(pos);
}
void solve(int N, int K, long long A, int S) {
int l = K, r = N;
while(l <= r){
int mid = (l + r) / 2;
ll a = 0;
vector<int> ans;
for(int i = mid - K + 1; i <= mid; i++){
ans.push_back(i);
a += get(i);
}
if(A <= a && a <= 2 * A){
answer(ans);
return;
}
else if(a < A){
l = mid + 1;
}
else if(2 * A < a){
r = mid - 1;
}
}
l = 1, r = N;
ll a = -1;
vector<int> ans(1);
while(l <= r){
int mid = (l + r) / 2;
if(get(mid) >= A){
r = mid - 1;
a = get(mid);
ans[0] = mid;
}
else{
l = mid + 1;
}
}
if(a == -1){
impossible();
return;
}
for(int i = 1; i < K; i++){
if(i == ans[0]){
impossible();
return;
}
ans.push_back(i);
a += get(i);
}
if(A <= a && a <= 2 * A){
answer(ans);
}
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... |