#K12261. Winning Team Ranking

    ID: 23652 Type: Default 1000ms 256MiB

Winning Team Ranking

Winning Team Ranking

You are given scores for n teams. Each team consists of three members and each member has a score. Your task is to determine the winning team according to the following ranking criteria:

  • Let the average score of a team be \(\frac{s_1+s_2+s_3}{3}\).
  • If two teams have the same average score, the team with the higher maximum individual score wins.
  • If still tied, the team with the higher second highest score wins.
  • If all three criteria are identical, the team with the lower index (first encountered) wins.

Note that teams are 1-indexed. That is, if the first team in the input is the winner, you should output 1.

Input and Output: You will read input from standard input and output the result to standard output.

inputFormat

The input begins with an integer n representing the number of teams. Following this, there are n lines, each containing three space-separated integers representing the scores of the three members of a team.

For example:

3
50 60 70
80 40 60
90 80 70

outputFormat

Output a single integer representing the 1-indexed winning team based on the ranking criteria described above.

## sample
3
50 60 70
80 40 60
90 80 70
3