1593:统计挤奶时间

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:6 解决:3

题目描述

三个农民每天清晨 lns="http://www.w3.org/1998/Math/MathML">5 点起床,然后去牛棚给三头牛挤奶。

第一个农民在 lns="http://www.w3.org/1998/Math/MathML">300 秒 (从 lns="http://www.w3.org/1998/Math/MathML">5 点开始计时) 给他的牛挤奶,一直到 lns="http://www.w3.org/1998/Math/MathML">1000 秒。第二个农民在 lns="http://www.w3.org/1998/Math/MathML">700 秒开始,在 lns="http://www.w3.org/1998/Math/MathML">1200 秒结束。第三个农民在 lns="http://www.w3.org/1998/Math/MathML">1500 秒开始,lns="http://www.w3.org/1998/Math/MathML">2100 秒结束。

期间最长的至少有一个农民在挤奶的连续时间为 lns="http://www.w3.org/1998/Math/MathML">900 秒 (从 lns="http://www.w3.org/1998/Math/MathML">300 秒到 lns="http://www.w3.org/1998/Math/MathML">1200 秒),而最长的无人挤奶的连续时间(从挤奶开始一直到挤奶结束)为 lns="http://www.w3.org/1998/Math/MathML">300 秒 (从 lns="http://www.w3.org/1998/Math/MathML">1200 秒到 lns="http://www.w3.org/1998/Math/MathML">1500 秒)。


你的任务是编一个程序,读入一个有 lns="http://www.w3.org/1998/Math/MathML">n 个农民挤 lns="http://www.w3.org/1998/Math/MathML">n 头牛的工作时间列表,计算以下两点(均以秒为单位):

最长至少有一人在挤奶的时间段。

最长的无人挤奶的时间段。(从有人挤奶开始算起)


输入

第一行一个正整数 lns="http://www.w3.org/1998/Math/MathML">n

接下来 lns="http://www.w3.org/1998/Math/MathML">n 行,每行两个非负整数 lns="http://www.w3.org/1998/Math/MathML">l,r,表示一个农民的开始时刻与结束时刻。对于 100\% 的数据,1\le n \le 50000 \le l \le r \le 10^6

输出

一行,两个整数,即题目所要求的两个答案。

样例输入-1 复制

3
300 1000
700 1200
1500 2100

样例输出-1 复制

900 300