Love for Games

0

0 votes
Medium
Problem

Students of Punjab Engineering College love games. They like to play games all the time. 
To make sure they remain happy their instructor decided to get games for them. 
But since they are students of Punjab Engineering College they are not so easily pleased.

A student would become happy if there at least X games and not more than Y games
because they know too much of games could lead to wastage of time. The instructor wants to buy the minimum number of games so that maximum number of students are happy in the college. Help him in finding out these values.

Input:
The first line contains N indicating the number of students in the college. 
This is followed up by N lines where every line contains two integers X and Y respectively.

Output:
Output two space-separated integers that denote the minimum number of games and the maximum number of happy students.

Constraints:
1<=N<=10^5
1<=X<=Y<10^9

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The teacher could buy 5 games and keep student 1, 2, 4 and 5 happy. 
He could also keep them happy by buying 6 games but we want the minimum value so it is 5.

Editor Image

?