欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1850B.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?
Input
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.
Output
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.
Note
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.
Samples
3
5
7 2
12 5
9 3
9 4
10 1
3
1 2
3 4
5 6
1
1 43
4
3
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |