#P13413. [COCI 2012/2013 #4] OREHNJACA

    ID: 15287 远端评测题 1000ms 32MiB 尝试: 0 已通过: 0 难度: 2 上传者: 标签>模拟2012Special JudgeCOCI(克罗地亚)

[COCI 2012/2013 #4] OREHNJACA

题目描述

These days, the TV studio has started shooting another new season of Jamie Oliver's cooking show. This season, Jamie plans to introduce the delights of Croatian cuisine to the world. In the first episode, the master chef has baked a walnut roll LL meters long, the longest ever baked in this part of the world. After hours of sweating and toiling in the kitchen, he has decided to reward each one of his NN faithful spectators in the studio.

He has chopped the walnut roll into one meter long chops and marked them with numbers from 11 do LL, from left to right. Each spectator has received a unique number ID (a positive integer from 11 to NN), as well as a paper with two integers, PP and KK. Each spectator was then allowed to take all chops from the PP-th to the KK-th, inclusive. Spectators were allowed to take their share in order of their ID numbers (spectator 11 first, followed by spectator 22, etc.). This order resulted in some spectators receiving fewer chops than they initially thought they would get. The following image corresponds to the first example test case:

1 2 3 4 5 6 7 8 9 10
1 3 2 3

Write a program to determine which spectator expected to get the most walnut roll chops, and which spectator actually got the most.

输入格式

The first line of input contains the positive integer LL (1L10001 \leq L \leq 1000), the length of the walnut roll.

The second line of input contains the positive integer NN (1N10001 \leq N \leq 1000), the number of spectators.

Each of the following NN lines contains two positive integers PiP_i and KiK_i (1PiKiL1 \leq P_i \leq K_i \leq L, i=1..Ni = 1..N), the values PP and KK as described in the problem statement for spectator number ii.

输出格式

The first line of output must contain the ID number of the spectator who was expecting to receive the most walnut roll chops.

The second line of output must contain the ID number of the spectator who actually received the most walnut roll chops in the end.

In both cases, if there is more than one spectator satisfying the condition, output the one with the smallest ID.

10
3
2 4
7 8
6 9
3
1
10
3
1 3
5 7
8 9
1
1
10
5
1 1
1 2
1 3
1 4
7 8
4
5

提示

If the first number is correct, the solution is awarded 60% of points for that test case, and if the second number is correct, the solution is awarded 40% of points for that test case.