This page is still under construction.

Parts of this page are still being built. What you see may change.

2017 Ajou Programming Contest (Large)

Time limit1sMemory limit512 MB

Summary
Given each contestant's score, submission count, and last scoring upload time, print the number of the first-place contestant.
Level

Easy2 of 10

Topics
Sorting
Solved
No attempts yet

Problem

The Ajou Programming Contest (APC) was a programming contest for Ajou University students, held from the first edition in 2009 to the sixth in 2014. In 2017, after watching the in-house contests that other schools kept running, Hyeonjeong decided to revive APC after a three year gap.

The 2017 APC runs like this.

  • Every problem comes in a Small data version and a Large data version.
  • To solve a problem you download the input file, then upload the matching output file and your source code within 5 minutes.
  • You can download the Large data input only after you solve the Small data.
  • Each problem has a fixed score for its Small data and for its Large data, and the two scores differ.
  • The submission count is the total number of input downloads taken, up to and including the correct one, on the problems that earned points.
  • Downloads on problems that earned no points are not added to the submission count.

Ranks follow these rules in order.

  • A contestant with a larger total score over the solved problems ranks higher.
  • If the total scores are equal, the contestant with fewer submissions ranks higher.
  • If the total score and the submission count are both equal, the contestant whose last scoring problem was uploaded earlier ranks higher.

Hyeonjeong has not slept properly for days and is in a foul mood. Write a program that computes the ranking of the contestants so she can rest for a while.

Input

The first line contains a natural number NN (1≤N≤100001 \le N \le 10000), the number of contestants.

Each of the next NN lines contains three integers SiS_i, CiC_i, LiL_i (0≤Si≤6200 \le S_i \le 620, 0≤Ci≤500 \le C_i \le 50, 0≤Li≤1790 \le L_i \le 179). The three values on line 1+i1+i are, in order, the score of contestant ii, the submission count, and the upload time of the last problem that earned points. No two contestants share all three values.

Output

Print the number of the contestant in first place on one line.

Examples6

  1. Example 1

    Input
    2
    620 7 179
    300 5 100
    
    Expected output
    1
    
  2. Example 2

    Input
    3
    300 5 100
    620 7 179
    600 9 150
    
    Expected output
    2
    
  3. Example 3

    Input
    1
    0 0 0
    
    Expected output
    1
    
  4. Example 4

    Input
    4
    500 3 50
    500 1 170
    500 2 10
    499 0 0
    
    Expected output
    2
    
  5. Example 5

    Input
    5
    100 10 90
    200 4 77
    200 4 76
    200 4 120
    199 0 0
    
    Expected output
    3
    
  6. Example 6

    Input
    3
    0 50 179
    0 50 178
    0 49 179
    
    Expected output
    3