#K33532. Maximum Blooming Months

    ID: 25108 Type: Default 1000ms 256MiB

Maximum Blooming Months

Maximum Blooming Months

Given a set of flower types and their blooming periods represented as intervals, your task is to determine the month or months during which the maximum number of distinct flower types are in bloom.

Each interval is given in the form \( (a, b) \), meaning that the flower blooms from month \( a \) to month \( b \) (inclusive). Months are represented by integers between 1 and 12. If there are multiple months with the same maximum number of blooms, output all such months in ascending order.

Note: Use standard input (stdin) and output (stdout) for the problem.

inputFormat

The input is given via standard input (stdin) with the following format:

N
start1 end1
start2 end2
... 
startN endN

Where:

  • N is the number of flower types.
  • Each of the next N lines contains two integers, start and end, representing the start and end month (inclusive) of the blooming period for a flower type.</p>

    outputFormat

    Print the month or months (separated by a single space) during which the maximum number of different types of flowers bloom. The months must be printed in ascending order.

    ## sample
    1
    1 3
    
    1 2 3
    

    </p>