#include <bits/stdc++.h>
using namespace std;
pair<vector<int>, long long> transaction(long long M);
void buy_souvenirs(int N, long long P0) {
vector<long long> P(N);
P[0] = P0;
vector<int> freq(N, 0);
int trials = 200;
for (int t = 0; t < trials; ++t) {
auto res = transaction(P0 - 1);
for (int x : res.first)
if (x < N) freq[x]++;
}
P[1] = P0 - 1;
for (int i = 2; i < N; ++i) {
if (freq[i] > freq[i - 1])
P[i] = P[i - 1] - 2;
else
P[i] = P[i - 1] - 1;
if (P[i] <= 0) P[i] = 1;
}
for (int t = 1; t < N; ++t) {
for (int rep = 0; rep < t; ++rep) {
long long M = P[t];
for (int j = N - 1; j > t; --j)
if (M + P[j] < P0)
M += P[j];
transaction(M);
}
}
}
| # | 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... |