Shop
Time limit2sMemory limit1024 MB
Given a product price and a percent range, find the cheapest candidate gift whose price falls between a and b percent of that price.
- Level
Easy2 of 10
- Topics
- Implementation, Array
- Solved
- No attempts yet
Problem
You are a middle manager at a store. Your boss has asked you to run a promotion that draws in customers. Under the promotion, a buyer who purchases one product receives another product as a gift.
You are given the product that will come with a gift. The gift must cost at least percent and at most percent of the product's price. For the store's benefit, the gift's price must be as low as possible.
Choose the gift for the given product.
Input
The first line contains the name of the product that will come with a gift. The second line contains the product's price (). The third line contains two positive integers and (). The fourth line contains (), the number of candidate gift products.
Each candidate is described by two lines. The first line is the candidate's name, and the second line is its price ().
All candidate prices are distinct. Names are at most 20 characters long and use characters with codes 32 to 127, which means Latin letters, punctuation, arithmetic signs, digits, and spaces.
Output
Print the name of the candidate chosen as the gift on a single line. The problem guarantees that such a candidate exists.