#P1850B. Ten Words of Wisdom
Ten Words of Wisdom
Ten Words of Wisdom
题面翻译
在一个比赛中,有 个参赛者,每个人都提交了一个回复,长度为 ,回复的质量为 ,在所有回复长度不超过 的回复中,找出质量最好的那一个人的编号。
题目描述
In the game show "Ten Words of Wisdom", there are participants numbered from to , each of whom submits one response. The -th response is words long and has quality . No two responses have the same quality, and at least one response has length at most .
The winner of the show is the response which has the highest quality out of all responses that are not longer than words. Which response is the winner?
输入格式
The first line contains a single integer ( ) — the number of test cases.
The first line of each test case contains a single integer ( ) — the number of responses.
Then lines follow, the -th of which contains two integers and ( ) — the number of words and the quality of the -th response, respectively.
Additional constraints on the input: in each test case, at least one value of satisfies , and all values of are distinct.
输出格式
For each test case, output a single line containing one integer ( ) — the winner of the show, according to the rules given in the statement.
It can be shown that, according to the constraints in the statement, exactly one winner exists for each test case.
样例 #1
样例输入 #1
3
5
7 2
12 5
9 3
9 4
10 1
3
1 2
3 4
5 6
1
1 43
样例输出 #1
4
3
1
提示
In the first test case, the responses provided are as follows:
- Response 1: words, quality
- Response 2: words, quality
- Response 3: words, quality
- Response 4: words, quality
- Response 5: words, quality
We can see that the responses with indices , , , and have lengths not exceeding words. Out of these responses, the winner is the one with the highest quality.
Comparing the qualities, we find that:
- Response 1 has quality .
- Response 3 has quality .
- Response 4 has quality .
- Response 5 has quality .
Among these responses, Response 4 has the highest quality.
相关
在以下作业中: