2017 Ajou Programming Contest (Large)
Time limit1sMemory limit512 MB
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 (), the number of contestants.
Each of the next lines contains three integers , , (, , ). The three values on line are, in order, the score of contestant , 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.