#C9594. The Strongest Monster
The Strongest Monster
The Strongest Monster
You are given data about k monsters. For each monster, you are provided with a list of integers where the first integer represents the hit points of the monster and the second integer indicates the number of prime factors following in the list. The remaining integers represent the prime factors found in the monster's genetic code. The strength of a monster is defined as:
\( \text{strength} = \text{hit points} \times \sum_{i=1}^{n} \text{primeFactor}_i \)
Your task is to determine the index (1-indexed) of the monster with the highest strength. In the event of a tie, choose the monster with the smallest index.
Input/Output format: Read input from stdin
and write the output to stdout
.
inputFormat
The first line contains a single integer k
, representing the number of monsters. Each of the following k
lines represents one monster. Each line starts with two integers. The first integer is the monster's hit points, and the second integer is the number of prime factors that follow. This is followed by that many integers representing the prime factors of the monster's genetic code.
For example, a line "10 2 2 3" represents a monster with 10 hit points and 2 prime factors: 2 and 3.
outputFormat
Output a single integer on stdout
denoting the 1-indexed position of the strongest monster.
1
10 2 2 3
1