Best Promo

An order may have several promo codes, but only one can be applied, so you need the one that gives the lowest final amount. Given an order amount total and a list promos, where each promo contains min_total and percent, use only promos where total is high enough. Apply the most beneficial valid promo and return the final amount rounded to two decimal places.

Примеры

Ввод
1000, [[500, 10], [2000, 50]]
Вывод
900
Ввод
1000, [[1000, 20], [800, 15]]
Вывод
800
Ввод
100, [[500, 50]]
Вывод
100

Нужно реализовать

def best_promo(total: float, promos: list) -> float:

Теги

arraymath
PostgreSQLv16

Tady se objeví výsledek běhu kódu

Visible tests
1
Input
1000, [[500,10],[2000,50]]
Expected900
2
Input
1000, [[1000,20],[800,15]]
Expected800
3
Input
100, [[500,50]]
Expected100
4
Input
200, []
Expected200
5
Input
3000, [[1000,5],[2500,30],[3000,25]]
Expected2100
6
Input
50, [[50,10]]
Expected45
Focus radio
Paused · SomaFM · Fluid