#C9832. TV Show Recommendation
TV Show Recommendation
TV Show Recommendation
You are given a list of TV shows and a user's preferences. Each show is described by its name, genre, number of episodes, and rating. Your task is to select the best TV show for the user such that:
- The show's genre exactly matches the user's preferred genre.
- The number of episodes is less than or equal to the user’s maximum episode limit.
If multiple shows meet the criteria, choose the one with the highest rating. If no show satisfies the conditions, output No suitable show found
.
Note: All ratings are non-negative integers and the input is read from standard input (stdin).
inputFormat
The input is provided via standard input (stdin) with the following format:
- The first line contains an integer
n
which is the number of TV shows. - The next
n
lines each contain four values separated by spaces: thename
(string),genre
(string),episodes
(integer), andrating
(integer) of the show. - The following line contains a string representing the user's preferred genre.
- The last line contains an integer representing the maximum number of episodes allowed.
outputFormat
Output a single line to standard output (stdout) containing the name of the recommended TV show. If no show meets the criteria, output No suitable show found
.
5
BreakingBad Drama 62 95
StrangerThings SciFi 34 90
GameOfThrones Fantasy 73 92
TheCrown Drama 50 89
Friends Comedy 236 85
Drama
60
TheCrown