Carousel Rides
Time limit1sMemory limit1024 MB
For each test case, pick the offer with the lowest price per ticket among those buying at most m tickets, breaking ties toward the offer that buys more tickets.
- Level
Easy2 of 10
- Topics
- Implementation, Brute force
- Solved
- No attempts yet
Problem
Carl likes to ride the carousel. Carousel operators often offer discounts for buying multiple rides. He wonders which of the discounts provides the best value.
Write a program to help him.
Input
The input contains multiple test cases. A test case starts with a line containing two numbers () and (). Carl does not take offers that require him to buy more than tickets. Next come lines, each with two numbers and , meaning an offer to buy tickets for $b. The input ends with a line containing 0 0.
Output
For each test case, print Buy a tickets for \$b for the best offer that Carl can use. If several offers tie, print the one that buys more tickets. If no offer is suitable, print No suitable tickets offered.