시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 97 | 70 | 51 | 71.831% |
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.
The input will contain multiple test cases. A test case starts with a line containing two numbers n (1 ≤ n ≤ 10) and m (1 ≤ m ≤ 20). Carl will not take advantage of offers that require him to buy more than m tickets. Following this are n lines, each with numbers a and b which each represent an offer to buy a tickets for $b.
The input will be terminated by a line containing the characters 0 0
.
For each test case, print Buy a tickets for $b
for the best offer that matches his requirements. If there are multiple best offers, print the one which buys more tickets. If there is no suitable offer, print No suitable tickets offered
.
3 5 1 3 3 5 4 7 3 2 3 5 1 3 4 7 3 2 3 6 1 2 2 4 1 3 4 10 0 0
Buy 3 tickets for $5 Buy 1 tickets for $3 Buy 2 tickets for $4 No suitable tickets offered
High School > Virginia Tech High School Programming Contest > 2014 Virginia Tech High School Programming Contest F번