#P6494. [COCI 2016/2017 #2] Go
[COCI 2016/2017 #2] Go
Description
In the game Evolve! Pokemon, Mirko has Pokemon. To complete their evolutions, Mirko has prepared candies for the -th Pokemon.
Each time he evolves the -th Pokemon, he must spend candies prepared for it. After the evolution is completed, Mirko will receive candies of the same type as a reward. Note that each Pokemon can only use its own corresponding candies to evolve.
Mirko wants to know how many evolutions he can complete in total, and which Pokemon can be evolved the most times. If the Pokemon with the maximum number of evolutions is not unique, choose the one that appears earlier in the input.
Input Format
The first line contains an integer .
The next lines:
-
Line contains a string, the name of Mirko's -th Pokemon.
-
Line contains two integers .
Output Format
The first line contains an integer, the total number of evolutions Mirko can complete.
The second line contains a string, the name of the Pokemon that can be evolved the most times.
4
Caterpie
12 33
Weedle
12 42
Pidgey
12 47
Rattata
25 71
14
Weedle
7
Bulbasaur
25 74
Ivysaur
100 83
Charmander
25 116
Charmeleon
100 32
Squirtle
25 1
Wartortle
100 173
Pikachu
50 154
11
Charmander
Hint
Sample 1 Explanation
For Weedle's first evolution, Mirko spends candies, then receives candies as a reward. At this time, there are candies left for Weedle to evolve. In this way, Mirko can evolve Weedle a total of times.
Similarly, Mirko can evolve Caterpies times, Pidgeys times, and Rattatas times. In total, he can complete evolutions, which is the first part of the answer.
Among them, Weedle and Pidgeys have the most evolutions, both times. Since Weedle appears earlier than Pidgeys in the input, Weedle is used as the second part of the answer.
Constraints
For of the testdata, , , .
All strings have length at most , and contain only uppercase and lowercase letters.
Notes
This problem is translated from COCI2016-2017 CONTEST #2 T1 Go。
Translated by ChatGPT 5
京公网安备 11011102002149号