Wild party P27158


Statement
 

pdf   zip

Masao’s life is hard. He lives in New York, earns good money by working for one of the best companies in the world, and his flat is usually crowded by beautiful models with liberal behaviors. Now Masao wants to choose the best moment for a party, but with so many gorgeous girls in and out of his flat, he is a bit confused. Poor Masao, indeed… can you help him?

Given the arrival time and leaving time of every model, Masao would like to know the maximum number of models that will be at his flat at the same time. Additionally, he would like to know the length of that nice event. This way, Masao could plan the wildest possible party!

Input

Input consists of several cases. Every case begins with the number of models 1n1051 \le n \le 10^5 (yes, 100000, Masao is like this). Follow nn pairs of integer numbers aa and \ell, which state that a model arrives at time aa and leaves at time \ell, with 0a<1090 \le a < \ell \le 10^9. A special case with n=0n = 0 marks the end of input.

Output

For every case, print the number of models and the length of the wildest possible party.

Public test cases
  • Input

    2   0 1000   2000 3500
    4   100 150  250 300  120 220  140 230
    3   1000 3000   4500 6000   3500 4500
    2   100 200   100 200
    0
    

    Output

    1 1500
    3 10
    1 2500
    2 100
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++