#include <bits/stdc++.h>
using namespace std;
vector<int> max_coupons(int A, vector<int> P, vector<int> T) {
int N = P.size();
vector<bool> used(N, false);
vector<int> result;
priority_queue<tuple<int, int, int>> pq;
for (int i = 0; i < N; ++i) {
pq.emplace(-T[i], P[i], i);
}
int token = A;
while (true) {
bool bought = false;
priority_queue<tuple<int, int, int>> temp;
while (!pq.empty()) {
auto [negT, price, idx] = pq.top(); pq.pop();
if (used[idx]) continue;
if (price <= token) {
token = (token - price) * T[idx];
result.push_back(idx);
used[idx] = true;
bought = true;
break;
} else {
temp.emplace(negT, price, idx);
}
}
while (!temp.empty()) {
pq.push(temp.top());
temp.pop();
}
if (!bought) break;
}
return result;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |