#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool cmp(array<ll, 3> &F, array<ll, 3> &S){
ll a = F[0], at = F[1];
ll b = S[0], bt = S[1];
ll x = bt * (-a * at - b);
ll y = at * (-b * bt - a);
if(at == 1 && bt == 1) return x > y;
if(x != y) return x < y;
return F[2] < S[2];
}
vector<int> max_coupons(int A, vector<int> P, vector<int> T){
int n = (int)P.size();
vector<array<ll, 3>> a(n);
for(int i = 0; i < n; i++){
a[i] = {P[i], T[i], i};
}
sort(a.begin(), a.end(), cmp);
vector<int> R;
ll val = A;
for(int i = 0; i < n; i++){
if(val < a[i][0]) break;
val = (val - a[i][0]) * a[i][1];
R.push_back(a[i][2]);
// cout << a[i][0] << " " << a[i][1] << " " << a[i][2] << '\n';
}
return R;
}
| # | 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... |