CF1445B.Elimination

入门

通过率:0%

时间限制:1.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 aa 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 bb points in the second contest.

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

有一场著名的奥林匹克竞赛,参赛者超过百人。该竞赛分为两个阶段:预选赛阶段和决赛阶段。至少有一百名参赛者将晋级决赛阶段。预选赛阶段本身又包含两场竞赛。

预选赛阶段的成绩为两场竞赛得分之和,但不幸的是,评委会丢失了最终的总分排名,仅保留了每场竞赛各自的独立排名。

在每场竞赛中,参赛者按其得分从高到低(非递增)排序;当两名参赛者得分相同时,按其护照号码排序(根据当地规定,所有护照号码互不相同)。

在第一场竞赛中,排名第 100 位的参赛者得分为 aa 分。此外,评委会核查了第一场竞赛中排名第 1 至第 100 位(含)的所有参赛者,发现他们第二场竞赛的得分均不少于 bb 分。

类似地,在第二场竞赛中,排名第 100 位的参赛者得分为 cc 分;且评委会核查确认,第二场竞赛中排名第 1 至第 100 位(含)的所有参赛者,第一场竞赛的得分均不少于 dd 分。

经过两场竞赛后,所有参赛者按其两场竞赛总分从高到低(非递增)排序;若总分相同,则按护照号码排序。晋级决赛阶段的分数线即为总分排名第 100 位的参赛者的总分。

给定整数 aa、bb、cc、dd,请帮助评委会确定该分数线可能的最小值。

输入格式

You need to process tt test cases.

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

The first line of each test case contains four integers aa, bb, cc, dd (0≤a, b, c, d≤90 \le a,\,b,\,c,\,d \le 9; d≤ad \leq a; b≤cb \leq c).

One can show that for any test case satisfying the constraints above, there is at least one olympiad scenario possible.

你需要处理 tt 个测试用例。

第一行包含一个整数 tt(1≤t≤30251 \leq t \leq 3025),表示测试用例的数量。随后是 tt 个测试用例的描述。

每个测试用例的第一行包含四个整数 aa、bb、cc、dd(0≤a, b, c, d≤90 \le a,\,b,\,c,\,d \le 9;d≤ad \leq a;b≤cb \leq c)。

可以证明:对于任意满足上述约束条件的测试用例,至少存在一种符合奥林匹克竞赛场景的方案。

输出格式

For each test case print a single integer — the smallest possible cutoff score in some olympiad scenario satisfying the given information.

对于每个测试用例,输出一个整数——即满足给定信息的某种奥赛场景下的最小可能的分数线。

输入输出样例

  • 输入#1

    2
    1 2 2 1
    4 8 9 2

    输出#1

    3
    12

说明/提示

For the first test case, consider the following olympiad scenario: there are 101101 participants in the elimination stage, each having 11 point for the first contest and 22 points for the second contest. Hence the total score of the participant on the 100-th place is 33.

For the second test case, consider the following olympiad scenario:

  • there are 5050 participants with points 55 and 99 for the first and second contest respectively;
  • 5050 participants with points 44 and 88 for the first and second contest respectively;
  • and 5050 participants with points 22 and 99 for the first and second contest respectively.

Hence the total point score of the participant on the 100-th place is 1212.

对于第一个测试用例,考虑以下奥林匹克竞赛场景:淘汰阶段共有 101101 名参赛者,每位参赛者在第一轮比赛和第二轮比赛中分别获得 11 分和 22 分。因此,排名第 100100 位的参赛者的总分为 33。

对于第二个测试用例,考虑以下奥林匹克竞赛场景:

  • 5050 名参赛者在第一轮和第二轮比赛中分别获得 55 分和 99 分;
  • 5050 名参赛者在第一轮和第二轮比赛中分别获得 44 分和 88 分;
  • 5050 名参赛者在第一轮和第二轮比赛中分别获得 22 分和 99 分。

因此,排名第 100100 位的参赛者的总分为 1212。

输入解题思路,AI测评打分。不知道怎么写?

首页