Codeforces Round #680 (Div. 2) B. Elimination(贪心)

题目链接:https://codeforc.es/contest/1445/problem/B

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 a 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 b points in the second contest.

Similarly, for the second contest, the participant on the 100-th place has c points. And the jury checked that all the participants from the 1-st to the 100-th place (inclusive) have at least d 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 a, b, c, d, please help the jury determine the smallest possible value of the cutoff score.

Input
You need to process t test cases.

The first line contains an integer t (1≤t≤3025) — the number of test cases. Then descriptions of t test cases follow.

The first line of each test case contains four integers a, b, c, d (0≤a,b,c,d≤9; d≤a; b≤c).

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.

Example

input

2
1 2 2 1
4 8 9 2

output

3
12

题意

进行两次比赛,每次比赛排名非递增顺序。
第一场第 100 名选手得 a 分,第二场每个选手最少得 b 分
第二场第 100 名选手得 b 分,第一场每个选手至少得 d 分
给你整数 a , b , c , d 问第 100 名选手至少总分多少

分析

这题关键就在于读懂题目,我看了好久没看懂
答案就是 max(a + b, c + d)

代码
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(a+b,c+d)<<endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值