#include "souvenirs.h"
#include <utility>
#include <vector>
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
void buy_souvenirs(int N, long long P0) {
// cerr << "P0: " << P0 << "\n";
auto [L, R] = transaction(P0 - 1);
R = P0 - 1 - R;
if (sz(L) == 1) {
// cerr << "L length 1\n";
// cerr << "R: " << R << "\n";
transaction(R - 1);
transaction(R - 1);
return;
}
assert(sz(L) == 2);
// cerr << "L length 2\n";
// cerr << "R: " << R << "\n";
ll m = R / 2;
transaction(m);
// std::pair<std::vector<int>, long long> res = transaction(3);
// P0 > P1 ... > P(N - 1) > 0
// -> first questions P0 - 1
// Let's solve N = 3
// Case1:
// we only buy one thing of price x
// -> we can next just try x - 1 and solved
// Case 2:
// we buy two things, total price s = P1 + P2:
// s / 2 is definitely smaller than P1 and larger(or equal) to P2.
//
return;
}
# | 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... |