Sauna

시간 제한1.5초메모리 제한1024 MB

요약
N개의 온도 범위가 주어질 때 모든 범위에 들어가는 온도의 개수와 그중 가장 낮은 온도를 구한다.
난이도

쉬움10점 중 2점

유형
배열, 구간, 구현
정답자
아직 제출이 없습니다

문제

Kaisa and her friends are going to the sauna!

Now they have to pick the temperature. Each of them has their own temperature preferences as an inclusive range of acceptable values. Can you help them find the temperatures that everyone is happy with?

Since there might be a large number of possible temperatures, they have asked you to just tell them how many options there are and what the lowest temperature that works for everyone is, as then the sauna will need less time to heat up.

입력

The first line of input contains an integer, NN, the number of people in the group (2≤N≤2⋅1052 \le N \le 2 \cdot 10^5). The next NN lines each contains two integers, a_ia\_i and b_ib\_i, indicating that the iith person's temperature preference is between a_ia\_i and b_ib\_i, inclusive. Temperatures are given in millidegrees Celsius, with 0≤a_i≤b_i≤2⋅1050 \le a\_i \le b\_i \le 2 \cdot 10^5.

출력

Output two integers: first, the number of different temperatures (in millidegrees Celsius) that fit all preferences; and second, the lowest such value.

If there are no values that fit all preferences, instead output "bad news".

예제2

  1. 예제 1

    입력
    3
    70000 70005
    70003 70010
    65000 80000
    
    예상 출력
    3 70003
    
  2. 예제 2

    입력
    2
    70000 70500
    80000 80100
    
    예상 출력
    bad news