| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1282097 | lukasuliashvili | Festival (IOI25_festival) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
vector<int> max_coupons(long long A, vector<long long>& P, vector<int>& T) {
int N = (int)P.size();
vector<int> idx(N);
iota(idx.begin(), idx.end(), 0);
sort(idx.begin(), idx.end(), [&](int i, int j){
if (P[i] != P[j]) return P[i] < P[j];
return T[i] > T[j];
});
long long tokens = A;
vector<bool> used(N,false);
vector<int> result;
int pos = 0;
priority_queue<pair<int,int>> pq;
while (true) {
while (pos < N && P[idx[pos]] <= tokens) {
int i = idx[pos];
pq.emplace(T[i], i);
pos++;
}
if (pq.empty()) break;
auto [mult, i] = pq.top();
pq.pop();
if (used[i]) continue;
used[i] = true;
result.push_back(i);
tokens = (tokens - P[i]) * mult;
}
return result;
}
