#K4221. Longest Continuous Sunlight

    ID: 27037 Type: Default 1000ms 256MiB

Longest Continuous Sunlight

Longest Continuous Sunlight

In this problem, you are given a list of intervals representing durations of sunlight during a day. Some intervals may overlap or be contiguous. Your task is to merge these intervals and then output the longest continuous interval of sunlight. In case of ties (i.e. intervals having the same duration), return the interval that appears first after merging. The duration of an interval ( [a, b] ) is calculated as ( b - a ).

inputFormat

The first line of input contains an integer ( n ) which is the number of intervals. The next ( n ) lines each contain two space-separated integers ( a ) and ( b ) (with ( a < b )), representing the start and end times of a sunlight interval.

outputFormat

Output the start and end time of the longest continuous sunlight interval as two space-separated integers on a single line.## sample

3
1 5
10 15
5 10
1 15

</p>