Best Gadget Pair

A shopper wants to buy exactly one keyboard and one drive without going over budget. The function get_money_spent receives price lists keyboards and drives, plus the budget b. Find the highest possible combined price that does not exceed the budget. If no pair can be bought, return -1.

Примеры

Ввод
[3, 1], [5, 2, 8], 10
Вывод
9
Ввод
[4], [5], 5
Вывод
-1
Ввод
[40, 50, 60], [5, 8, 12], 60
Вывод
58

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

def get_money_spent(keyboards: list[int], drives: list[int], b: int) -> int:

Теги

arraytwo-pointersmath
PostgreSQLv16

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

Visible tests
1
Input
[3,1], [5,2,8], 10
Expected9
2
Input
[4], [5], 5
Expected-1
3
Input
[40,50,60], [5,8,12], 60
Expected58
4
Input
[1,2,3], [4,5,6], 100
Expected9
5
Input
[10], [10], 20
Expected20
6
Input
[4,2], [5,2,8,5,2], 9
Expected9
Focus radio
Paused · SomaFM · Fluid