#C10587. Winning Team by Top Two Scores

    ID: 39808 Type: Default 1000ms 256MiB

Winning Team by Top Two Scores

Winning Team by Top Two Scores

In this problem, you are given scores of several teams. Each team has exactly three scores. Your task is to determine the winning team. The winning team is defined as the team with the highest sum of its two highest scores. In case of a tie, the team that appears first (i.e. with the lowest index) is considered the winner.

Formally, let the scores of the i-th team be denoted by (a_i), (b_i), (c_i). Define (S_i = \text{sum of the two largest scores among } {a_i, b_i, c_i}). The winning team is the one with the maximum (S_i). Note that the answer should be 1-indexed (i.e. teams are numbered from 1 onwards).

For example, if the input teams are:

  • Team 1: 4 8 6 (top two: 8 and 6, sum = 14)
  • Team 2: 7 5 9 (top two: 9 and 7, sum = 16)
  • Team 3: 5 5 5 (top two: 5 and 5, sum = 10)
The winning team would be Team 2.

inputFormat

The input will be given via standard input (stdin). The first line contains a single integer (T) indicating the number of teams. This is followed by (T) lines, each containing three integers separated by spaces, representing the scores of the team.

outputFormat

Output a single integer to standard output (stdout): the 1-indexed number of the winning team based on the sum of the top two scores.## sample

3
4 8 6
7 5 9
5 5 5
2

</p>