#C11370. Trail Selector
Trail Selector
Trail Selector
Liam loves hiking, but after hiking several trails in the past, he now wants to try a new adventure. Given a list of trails he has already hiked and a list of available trails for this week (each with its length), your task is to help Liam select a new trail. The chosen trail must be one that he hasn't hiked before and among those, it should be the one with the maximum length. If all available trails have already been hiked, print No new trails this week!
.
Input/Output Requirements: Your program should read from standard input and write to standard output.
Note on Input Format: Trail names may contain spaces. For the offered trails, the trail name and the integer length are provided on the same line, where the integer (representing the length) is the last token of that line.
inputFormat
The input is given via standard input and has the following format:
- An integer N representing the number of trails Liam has already hiked.
- N lines follow, each containing the name of a hiked trail.
- An integer M representing the number of trails offered this week.
- M lines follow, each describing an offered trail. Each line contains the trail name (which may include spaces) and an integer representing its length. The integer is guaranteed to be the last token in the line.
outputFormat
Output a single line to standard output containing the name of the selected trail. If there is no valid trail (i.e., all offered trails have been hiked before), output No new trails this week!
.
0
2
River Valley 10
Forest Path 14
Forest Path
</p>