Pokemon GO
Time limit1sMemory limit32 MB
For each species, compute how many net 10-candy evolutions are possible, sum them, and find the species with the most evolutions.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem

Ash started the mobile game Pokemon GO. In this game you can evolve your Pokemon.
Evolving a Pokemon once costs candies of that species. When the evolution finishes, 2 candies come back. A Pokemon evolves only with candies of its own species.
Ash has species, and he holds candies of species . The returned candies can be spent on the next evolution, so he keeps evolving the same species until the candies run short. For example, with and each evolution costs a net 10 candies, so he evolves 4 times: he evolves at 42, 32, 22 and 12 candies, and 2 candies are left at the end.
Find the total number of Pokemon Ash can evolve, and the name of the species he can evolve the most times. If several species tie, print the one with the smallest Pokedex number, that is, the one that appears earlier in the input. If not a single Pokemon can be evolved, print 0 and then the name of the species that appears first in the input.
Input
The first line contains the number of species ().
The next lines contain data sets.
- Line contains the name of the -th Pokemon. Its length is at most 20.
- Line contains the number of candies one evolution of the -th Pokemon costs, (), and the number of candies of that species Ash holds, (), separated by a space.
Output
On the first line, print the total number of Pokemon that can be evolved.
On the second line, print the name of the species that can be evolved the most times.