#C5524. Album Cover Selection

    ID: 49183 Type: Default 1000ms 256MiB

Album Cover Selection

Album Cover Selection

You are given a collection of albums. Each album contains a set of photos, and each photo has a unique photo id and a creation timestamp.

The cover image of an album is defined as the photo with the maximum (latest) timestamp. Your task is to identify the cover images of all albums (ignore albums that have no photos), then sort and output the photo ids of these cover images in descending order of their corresponding timestamps.

In other words, if the cover photo of an album is the one with the largest timestamp, then you need to sort these chosen photos so that the one with the most recent timestamp is printed first, followed by the next, and so on.

It is guaranteed that if an album has photos, there will be a unique photo with the latest timestamp.

Note: All formulas (if any) should be written in LaTeX format. For example, the timestamp comparison can be represented as: \(a < b\) if timestamp of photo a is less than that of photo b.

inputFormat

Input is read from standard input (stdin). The first line contains an integer (n), which represents the number of albums. For each album, the following lines are provided:

  1. A line with the album name (a string without spaces).
  2. A line with an integer (m) representing the number of photos in the album.
  3. (m) subsequent lines, each containing two space-separated integers: the photo id and the creation timestamp.

Albums with (m = 0) (i.e., no photos) are ignored.

outputFormat

Output to standard output (stdout) a single line containing the cover photo ids separated by a space, sorted by their creation timestamps in descending order. If no album has any photos, output an empty line.## sample

2
Vacation
2
1 1636025600
2 1636112000
Birthday
1
3 1635842800
2 3

</p>