39. Poke Battle

Time Limit: 2 seconds

Memory Limit: 1024 MB

Rating: 1200

Problem Statement

You are betting on Pokemon battles and need to predict who you think is going to win the battle. There is a list of Pokemons. Pokemon battle in pairs and keep battling until only one of them is left standing. You are given their name, health, damage, and speed respectively. A fight consists of multiple rounds. On each round, pokemon with a higher speed attack first, then the other pokemon attacks. The speed of the Pokemon which attacks first is reduced by $10%$. If the speed of both pokemons is equal, the pokemon on the left (top one) attacks first. Pokemons heal after every fight to full health. After each fight, their speed also returns to its original value. Determine who will be the last one standing.

Input

You are first given an integer $n$, the number of Pokemons. The number of Pokemons you receive will always be a power of $2$. $(1 \le n \le 128)$ You are then given a list of $n$ Pokemons which represents the Pokemons and their battle order.

Output

Output the name of the Pokemon who will win the tournament.

Sample Cases
Sample Input 1:
4
charizard 5 10 20
pikachu 80 50 5
squirtle 50 5 50
bulbasaur 200 1 2

Sample Output 1:
pikachu


Sample Input 2:
8
Charizard 300 10 20
pikachu 80 50 5
squirtle 50 5 50
bulbasaur 200 1 2
metapod 50 5 5
beedril 80 150 100
arcanine 200 100 10
alakazam 100 25 25

Sample Output 2:
arcanine
Explanation

Not available for this problem.

Sources

KL Coding Cup March 2023 > Pokemon > Problem 3

Submit | Back