#C2585. Optimal Car Rental Selection Problem
Optimal Car Rental Selection Problem
Optimal Car Rental Selection Problem
You are given a budget \(B\) and a list of daily rental costs for a set of cars. For each test case, determine which car should be rented to maximize the number of rental days. The number of days you can rent a car is given by \(\lfloor\frac{B}{cost}\rfloor\), where \(\lfloor \cdot \rfloor\) denotes the floor function.
If more than one car yields the same maximum number of rental days, choose the one with the lower daily cost. If no car is affordable within the given budget, output Not Affordable.
inputFormat
The first line contains an integer (T) denoting the number of test cases. Each test case consists of two lines. The first line contains two integers: (B) (the budget) and (N) (the number of available cars). The second line contains (N) space-separated integers, each representing the daily rental cost of a car.
outputFormat
For each test case, output a single line containing the daily cost of the selected car, or output Not Affordable if no car can be rented within the budget.## sample
3
1000 3
500 300 700
500 4
400 600 800 1000
150 2
200 250
300
400
Not Affordable
</p>