#C10868. Minimum Songs for Full Year Coverage
Minimum Songs for Full Year Coverage
Minimum Songs for Full Year Coverage
You are given an integer n representing the number of songs, followed by n lines, each containing two space‐separated integers: a song's identifier and its release year. A complete playlist is defined as a selection of songs that includes at least one song from every year in the range \( [2000, 2019] \).
Your task is to determine the minimum number of songs required to form such a complete playlist. In other words, if it is possible to pick one song per year from \(2000\) to \(2019\), then output the number of songs in the playlist (which will always be \(20\)). Otherwise, if any year in that range is missing from the list, output an error message in the following format:
No songs available for the year Y
where Y
is the first (smallest) year in the range \( [2000, 2019] \) that does not have any available song.
Note: The input is provided via standard input (stdin) and the output should be written to standard output (stdout). All formulas are written in LaTeX format.
inputFormat
The first line contains an integer \(n\) \( (1 \leq n \leq 10^5)\), the number of songs. Each of the following \(n\) lines contains two space-separated integers: the first is the song's identifier, and the second is its release year. The release year will be in the range \([2000, 2019]\) if available.
outputFormat
If it is possible to form a complete playlist (i.e. there is at least one song for every year from \(2000\) to \(2019\)), print the integer \(20\) (the minimum number of songs needed). Otherwise, print the error message No songs available for the year Y
, where \(Y\) is the first missing year in the range.
20
1 2000
2 2001
3 2002
4 2003
5 2004
6 2005
7 2006
8 2007
9 2008
10 2009
11 2010
12 2011
13 2012
14 2013
15 2014
16 2015
17 2016
18 2017
19 2018
20 2019
20
</p>