#include <bits/stdc++.h>
#include "books.h"
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define pii pair<int,int>
#define pll pair<long long, long long>
// permutation of the last layer
#define LOO(i,a,b) for (int i = a; i <= b; i++)
#define max3(a, b, c) max(max(a, b), c)
#define min3(a, b, c) min(min(a, b), c)
using namespace std;
void solve(int N, int K, long long A, int S) {
// we dont have to do binary search save scumming cuz kinda nice restraints fr;
//cout << "so good so far" << endl;
int l = 1;
int r = N;
while (r>l) {
int mid = (l+r)/2;
if (skim(mid) < A) {
l = mid + 1;
}
else {
r = mid;
}
}
int bigger_thana = -1;
if (r==l) bigger_thana = l;
else {impossible();return;}
// cout << "so good so far" << endl;
l = 1;
r = N;
while (r>l) {
int mid = r - (l+r)/2;
if (skim(mid) <= 2*A) {
r = mid;
}
else {
l = mid + 1;
}
}
int smaller_thana = -1;
if (r==l) smaller_thana = l;
else {impossible();return;}
if (bigger_thana - smaller_thana + 1 >= K) {
vector<int> ans = {};
for (int i = smaller_thana; i < smaller_thana + K; i++) {
ans.push_back(i);
}
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... |