欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1243A.Maximum Square
Maximum Square
Ujan decided to make a new wooden roof for the house. He has rectangular planks numbered from to . The -th plank has size (that is, the width is and the height is ).
Now, Ujan wants to make a square roof. He will first choose some of the planks and place them side by side in some order. Then he will glue together all of these planks by their vertical sides. Finally, he will cut out a square from the resulting shape in such a way that the sides of the square are horizontal and vertical.
For example, if Ujan had planks with lengths , , , and , he could choose planks with lengths , and . Then he can cut out a square, which is the maximum possible. Note that this is not the only way he can obtain a square.

What is the maximum side length of the square Ujan can get?
Input
The first line of input contains a single integer (), the number of test cases in the input.
For each test case, the first line contains a single integer (), the number of planks Ujan has in store. The next line contains integers (), the lengths of the planks.
Output
For each of the test cases, output a single integer, the maximum possible side length of the square.
Note
The first sample corresponds to the example in the statement.
In the second sample, gluing all planks will result in a square.
In the third sample, the maximum possible square is and can be taken simply as any of the planks.
Samples
4
5
4 3 1 4 5
4
4 4 4 4
3
1 1 1
5
5 5 1 1 5
3
4
1
3
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |