#C14162. Highest Rated Movie of the Second User
Highest Rated Movie of the Second User
Highest Rated Movie of the Second User
You are given data for n users. Each user has a name, an age and a list of their preferred movies along with a rating for each movie. The input begins with an integer n
(with n \ge 2
). Then for each user, the following data is provided:
- A line containing a string
userName
and an integerage
separated by a space. - A line containing an integer
m
which denotes the number of movies in the user's preferred list. m
lines follow, each containing a movie title (a single word without spaces) and its rating (an integer), separated by a space.
Your task is to find the movie with the highest rating from the second user (i.e. the user appearing second in the input order). If there are multiple movies with the same highest rating, output the first one encountered in the input.
All outputs should be printed to stdout.
inputFormat
The first line contains an integer n
(number of users, n \ge 2
). For each of the next n
users, the input is structured as follows:
- A line with the user's name (string) and age (integer), separated by a space.
- A line with an integer
m
, the number of movies. m
subsequent lines, each with a movie title (a single word without spaces) and a movie rating (integer), separated by a space.
outputFormat
Output a single line containing the title of the movie with the highest rating from the second user's list. If there is a tie for the highest rating, output the movie that appeared first in the second user's list.
## sample3
Alice 25
2
Inception 5
Interstellar 4
Bob 30
2
TheMatrix 5
JohnWick 3
Charlie 28
2
Avatar 4
Titanic 5
TheMatrix