Editorial for WC '16 Contest 2 J1 - The Perfect Mate
Submitting an official solution before solving the problem yourself is a bannable offence.
We'll need to iterate over all warriors, inputting their information and keeping track of the best mate seen so far. We'll need to remember both this optimal mate's name (so that it can be outputted at the end), and his number of victories (so that we can determine if a superior mate is found). For convenience, we can initialize his name as None
and victory count as . In this way, any suitable mate will replace him, and if no suitable mates are found, we'll proceed to output None
.
When we consider each warrior, we should simply ignore them if they've lost more than battles. Otherwise, they should become the new optimal mate if they've won strictly more battles than the previous mate has. If they've only won an equal number of battles, the previous optimal mate should be retained, as they appeared earlier in the list.
Comments