408105: GYM102986 A Favorite Foods

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Favorite Foodstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Francesca is compiling a list of her favorite (and least favorite) foods to help with meal planning. She gives an integer rating for each of $$$n$$$ different foods, where a higher rating indicates that Francesca likes the food more. Obviously, Francesca would prefer to prepare foods with a high rating more often and prepare foods with a low rating less often.

Given the list of foods and ratings Francesca has given for each food, figure out Francesca's least favorite food (food with the lowest rating) and her favorite food (food with the highest rating). It is guaranteed that each food rating will be distinct and the same food will not appear multiple times on Francesca's list.

Input

The first line of the input consists of a single integer $$$n$$$ $$$(1 \leq n \leq 50)$$$, giving the number of foods that Francesca has given a rating for. The next $$$n$$$ lines each consist of a single token food name $$$f_i$$$ $$$(1 \leq |f_i| \leq 30)$$$ and a rating $$$r_i$$$ associated with that food $$$(-10^9 \leq r_i \leq 10^9)$$$. $$$f_i$$$ will always consist of only uppercase and lowercase letters.

Output

Output Francesca's least favorite food and favorite food, separated by a space.

ExampleInput
3
Sandwiches 23
Sardines -2
Pizza 23984
Output
Sardines Pizza

加入题单

上一题 下一题 算法标签: