题库练习 [COCI-2016_2017-contest2]#2 Go
← 上一题 下一题 →

A1339 | [COCI-2016_2017-contest2]#2 Go

来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0

题目描述

Mirko quickly got tired of Jetpack Joyride and started playing Pokémon GO! on his phone.
One of the curiosities of this game is the so-called evolution of Pokémon.
In order to evolve Pokémon of species Pi , Mirko must provide Ki candy intended for a Pokémon of that species. After the evolution of that Pokémon, he gets 2 candies back.
Pokémon can evolve only​ with the help of candy intended for their species.
Mirko has N species of Pokémon and Mi candy for Pokémon of species Pi and wants to know how many total Pokémon he can evolve.
He also wants to know which Pokémon can evolve the most number of times. If there are multiple such Pokémon, output the one with the smallest Pokédex number. In other words, the one that appears earliest in the input data.

输入格式

The first line of input contains the integer N (1 ≤ N ≤ 70), the number of Pokémon species.
The following 2N lines contains N sets of data, wherein it holds:
● line 2i contains string Pi , 20 characters long at most, the name of the i^th Pokémon species;
● line 2i+1 contains integers Ki ​(12 ≤ Ki ≤ 400) and Mi (1 ≤ Mi ≤ 10^4 ), the number of candy necessary for the evolution of one Pokémon of the i th species and the total number of candy Mirko has for Pokémon of the i^th species

输出格式

The first line of output must contain the total number of Pokémon that Mirko can evolve.
The second line of output must contain the name of the Pokémon that can evolve the most number of times.

输入输出样例

输入 #1
4 
Caterpie 
12 33 
Weedle 
12 42 
Pidgey 
12 47 
Rattata 
25 71
输出 #1
14 
Weedle
输入 #2
7 
Bulbasaur 
25 74 
Ivysaur 
100 83 
Charmander 
25 116 
Charmeleon 
100 32 
Squirtle 
25 1 
Wartortle 
100 173 
Pikachu 
50 154
输出 #2
11 
Charmander
C++ 编辑器
输入
输出