#K49052. Highest Effectiveness Warrior
Highest Effectiveness Warrior
Highest Effectiveness Warrior
You are given a set of battle scenarios in the kingdom of Westeros. In each scenario, there are several warriors and each warrior has two attributes: attack power and defense power. There are strictly three types of warriors available: Knight, Archer, and Mage. The combat effectiveness of a warrior is defined by the formula: \(E = A + D\), where \(A\) is the attack power and \(D\) is the defense power.
For each scenario, determine the warrior type that has the highest overall combat effectiveness. In case of a tie in effectiveness, the priority order is Knight first, then Archer, and finally Mage.
Note: The number of warriors in a scenario is provided by the input and will not exceed 3. The mapping is as follows:
- For the first warrior, type is
Knight
- For the second warrior (if any), type is
Archer
- For the third warrior (if any), type is
Mage
Your task is to read multiple scenarios, compute the warrior with the highest combat effectiveness for each, and output the corresponding warrior type on a new line.
inputFormat
The first line of the input contains two integers N and M, where N is the number of scenarios and M is the number of warriors in each scenario.
This is followed by N lines, each containing 2*M space-separated integers. The integers are given in pairs; the first integer of a pair represents the attack power and the second integer represents the defense power of a warrior.
\(\textbf{Input Format:}\)
N M A1 D1 A2 D2 ... AM DM ... (N lines in total)
outputFormat
For each scenario, output one line containing the type of warrior with the highest combat effectiveness. Valid outputs are Knight
, Archer
, or Mage
.
2 3
10 15 20 25 30 35
40 50 20 30 15 10
Mage
Knight
</p>