Editorial for COCI '16 Contest 2 #1 Go


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

In order to calculate E_i, the number of Pokémon of type P_i that Mirko can evolve, we must implement the algorithm given in the following pseudocode:

Ei = 0
while Mi >= Ki :
    Mi = Mi - Ki + 2
    Ei = Ei + 1

Alternatively, we can use the following formula:

\displaystyle E_i = \max\left(\left\lfloor \frac{M_i-2}{K_i-2} \right\rfloor, 0\right)

Why this formula is suitable is left as an exercise for the reader.

Now that we have calculated all E_i, all that's left is to output the sum of all E_i and the first Pokémon P_i that has the largest E_i.


Comments

There are no comments at the moment.