#P1702. 突击考试

突击考试

Description

One day, the teacher decides to hold a surprise exam. It is known that each student has an ability level. There are NN desks in the classroom, arranged in a single row. Each desk can seat two students; the two students at desk ii have ability levels AiA_i and BiB_i. The teacher now decides to test people whose ability level is KK. He will choose LL consecutive desks from these NN desks for the exam, requiring that each of these LL desks has at least one person whose ability level is KK. We want to determine the maximum possible LL and the corresponding KK.

Input Format

Line 1: an integer NN.

Lines 2 to N+1N+1: each line contains two integers, AiA_i and BiB_i.

Output Format

Output two integers LL and KK, where LL is maximized; among those, choose the smallest possible KK.

3
3 5
4 5
1 3

2 5

Hint

Constraints

For all testdata, 1N100,0001 \le N \le 100{,}000, 1Ai,Bi51 \le A_i, B_i \le 5.

Translated by ChatGPT 5