Grocery Shopping
Time limit1sMemory limit128 MB
Pick the crab stick bag with the highest grams per won, breaking ties by the lowest price.
- Level
Easy1 of 10
- Topics
- Brute force, Math
- Solved
- No attempts yet
Problem
Hyeseon eats crab sticks often, so she went to a mart near her home to buy some. Standing in front of the food aisle, she ran into a problem. Each brand puts a different weight in a bag at a different price, so it was not obvious which bag would let her eat the most for the same money.
Hyeseon wrote down the weight in grams and the price in won printed on every bag on display, and decided to buy the one with the largest weight per won, that is, the one with the largest . Write a program that finds the price of the crab sticks Hyeseon should buy.
Input
Input is read from standard input. The first line contains the number of test cases ().
The first line of each test case contains the number of crab stick kinds . Each of the next lines contains the weight in grams and the price in won of one kind, in that order, separated by a single space. (, , , and and are integers.)
Output
Output is written to standard output. For each test case, print the price of the crab sticks Hyeseon should buy, one per line. If two or more kinds tie for the largest weight per won, she buys the cheapest one among them.