#B4054. Battle Leader Selection

    ID: 11711 Type: Default 1000ms 256MiB

Battle Leader Selection

Battle Leader Selection

In a fierce battle, each warrior is evaluated by three parameters: \(K\), \(D\), and \(A\). The strength of a warrior is determined by the following rules:

  • If \(K-D \ge 10\), then the strength is \(K \times (K-D) + A\).
  • If \(K-D < 10\) but \(K \ge D\), then the strength is \((K-D+1) \times 3 + A\).
  • If \(K < D\), then the strength is \(A \times 2\).

There are \(n\) warriors participating in the battle. The warrior with the highest strength will be chosen as the leader. It is guaranteed that there is only one warrior with the maximum strength. Your task is to determine the 1-indexed position of the leader.

inputFormat

The first line contains a single integer \(n\) representing the number of warriors.
Each of the following \(n\) lines contains three space-separated integers \(K\), \(D\), and \(A\).

outputFormat

Output one integer representing the 1-indexed position of the warrior who becomes the leader.

sample

3
20 5 3
15 10 2
8 10 5
1