#K2171. Sort Movies
Sort Movies
Sort Movies
You are given a list of movies represented as pairs of integers. Each movie is represented as a tuple \( (r, y) \) where \( r \) denotes the movie's rating, and \( y \) denotes its release year. Your task is to sort these movies in descending order by rating. For movies with the same rating, sort them in ascending order by release year.
You can think of the sort key as \( (-r, y) \). That is, if you have two movies \( (r_1, y_1) \) and \( (r_2, y_2) \), then movie 1 comes before movie 2 if either \( r_1 > r_2 \) or \( r_1 = r_2 \) and \( y_1 < y_2 \).
inputFormat
The input is read from standard input (stdin). The first line contains a single integer n, representing the number of movies. The following n lines each contain two integers separated by a space: the rating and the release year of a movie.
outputFormat
Output the sorted movies to standard output (stdout). Each line should contain two integers (rating and release year) separated by a space, following the sorted order.## sample
5
8 2001
9 1998
8 1999
7 1995
9 2000
9 1998
9 2000
8 1999
8 2001
7 1995
</p>