Leaderboard Standings
Practice
3.4 (15 votes)
Algorithms
Easy
Hash maps
Sorting
Problem
75% Success 3930 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

There were \(N\) submissions made in a programming contest containing infinite problems. Each submission earned the contestant \(100 \) points as none of the submissions is a wrong or a partial submission. You are given the details of the submissions - the username of the contestant and the time taken to solve the problem. Your task is to print the rank list according to the following rules:

  1. The contestant with a higher score gets a higher rank.
  2. If the scores are tied, then the contestant with the least sum of the time taken to solve the problems gets a higher rank.
  3. In case of a tie in both scores and sum of the time taken, they are ranked lexicographically according to their usernames. 

Note: The details of the submissions are not sorted in any order (neither by time nor by username)


INPUT FORMAT

The first line of every test file contains an integer \(N\), the number of submissions. \(N\) lines follow, each being the details of \(i\)th submission. 

Each of the \(N\) lines contains a string \(C_i\), the username of the contestant corresponding to \(i^{th}\) submission, and an integer \(T_i\), the time of submission in minutes, separated by a space.


OUTPUT FORMAT

Output the rank of the contestant and the username, in the increasing order of the ranks. Each rank should be displayed in a newline.


CONSTRAINTS

\(1 \le N \le 10^6\)

\(1 \le len(C_i) \le 10\) where \(len(s)\) denotes the length of the string s

\(1 \le T_i \le 120\)

Number of unique usernames are at most \(10^5\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
20 votes
Tags:
ArraysBasic ProgrammingEasy
Points:20
8 votes
Tags:
Ad-HocApprovedEasyPriority queueapproved
Points:20
159 votes
Tags:
Ad-HocApprovedEasyOpen