欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1445B.Elimination
Elimination
There is a famous olympiad, which has more than a hundred participants. The Olympiad consists of two stages: the elimination stage, and the final stage. At least a hundred participants will advance to the final stage. The elimination stage in turn consists of two contests.
A result of the elimination stage is the total score in two contests, but, unfortunately, the jury lost the final standings and has only standings for the first and for the second contest separately.
In each contest, the participants are ranked by their point score in non-increasing order. When two participants have a tie (earned the same score), they are ranked by their passport number (in accordance with local regulations, all passport numbers are distinct).
In the first contest, the participant on the 100-th place scored points. Also, the jury checked all participants from the 1-st to the 100-th place (inclusive) in the first contest and found out that all of them have at least points in the second contest.
Similarly, for the second contest, the participant on the 100-th place has points. And the jury checked that all the participants from the 1-st to the 100-th place (inclusive) have at least points in the first contest.
After two contests, all participants are ranked by their total score in two contests in non-increasing order. When participants have the same total score, tie-breaking with passport numbers is used. The cutoff score to qualify to the final stage is the total score of the participant on the 100-th place.
Given integers , , , , please help the jury determine the smallest possible value of the cutoff score.
Input
You need to process test cases.
The first line contains an integer () — the number of test cases. Then descriptions of test cases follow.
The first line of each test case contains four integers , , , (; ; ).
One can show that for any test case satisfying the constraints above, there is at least one olympiad scenario possible.
Output
For each test case print a single integer — the smallest possible cutoff score in some olympiad scenario satisfying the given information.
Note
For the first test case, consider the following olympiad scenario: there are participants in the elimination stage, each having point for the first contest and points for the second contest. Hence the total score of the participant on the 100-th place is .
For the second test case, consider the following olympiad scenario:
- there are participants with points and for the first and second contest respectively;
- participants with points and for the first and second contest respectively;
- and participants with points and for the first and second contest respectively.
Hence the total point score of the participant on the 100-th place is .
Samples
2
1 2 2 1
4 8 9 2
3
12
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |