欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1610C.Keshi Is Throwing a Party
Keshi Is Throwing a Party
CF1610C · Keshi Is Throwing a Party
- 难度:1600
- 标签:binary search、greedy
- 链接:https://codeforces.com/problemset/problem/1610/C
- 时间限制:1 second 内存限制:256 megabytes
- 出现位置:Day29-阶段模拟8-高压综合卷
英文原题面
Statement
Keshi is throwing a party and he wants everybody in the party to be happy. He has friends. His -th friend has dollars. If you invite the -th friend to the party, he will be happy only if at most people in the party are strictly richer than him and at most people are strictly poorer than him. Keshi wants to invite as many people as possible. Find the maximum number of people he can invite to the party so that every invited person would be happy.
Input
The first line contains a single integer — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer — the number of Keshi's friends. The -th of the following lines contains two integers and . It is guaranteed that the sum of over all test cases doesn't exceed .
Output
For each test case print the maximum number of people Keshi can invite.
样例
样例 1
输入:
3
3
1 2
2 1
1 1
2
0 0
0 1
2
1 0
0 1
输出:
2
1
2
样例解释(英文原文)
In the first test case, he invites the first and the second person. If he invites all of them, the third person won't be happy because there will be more than person poorer than him.
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |