UptoSkills Arena Ranker
The UptoSkills Arena needs to rank students for an upcoming event. The ranking criteria are simple: first, sort by the number of problems solved in ascending order. If two students solved the same number of problems, sort them by their college ID in ascending order. Given a list of students with their problem counts and college IDs, print their ranking.
Input
The first line contains an integer N, the number of students. The next N lines each contain two integers: the number of problems solved (P) and the college ID (C).
Output
Print N lines, each containing the college ID of a student in the ranked order.
Constraints
1 <= N <= 1000 0 <= P <= 1000 1 <= C <= 100000
Example 1
4 5 101 3 102 5 100 2 103
103 102 100 101
Students are ranked by problems solved (2, 3, 5, 5), then by ID for ties (100 before 101).
Example 2
3 10 50 10 40 10 60
40 50 60
All students solved 10 problems, so they are ranked by ID (40, 50, 60).
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
4 5 101 3 102 5 100 2 103
3 10 50 10 40 10 60