CF2266A.Good Contest

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The next programming contest has three problems and nn participants.

Problem 11 is easy, problem 22 is medium, and problem 33 is hard.

A participant is called weak if they did not solve all three problems.

Unfortunately, the scoreboard was lost. The only remaining information is an array aa of length 33, where aia_i is the number of participants who solved problem ii.

Among all scoreboards consistent with this information, find the minimum possible number of weak participants.

下一届编程竞赛共有三道题目和 nn 名参赛者。

第 11 题简单,第 22 题中等,第 33 题困难。

若一名参赛者未解出全部三道题目,则称其为“弱参赛者”。

不幸的是,记分板丢失了。目前仅剩一个长度为 33 的数组 aa,其中 aia_i 表示解出第 ii 题的参赛者人数。

在所有与该信息一致的记分板中,求弱参赛者的最少可能人数。

输入格式

The first line contains an integer tt (1≤t≤30001 \le t \le 3000) — the number of test cases.

The first line of each test case contains an integer nn (1≤n≤91 \le n \le 9) — the number of participants.

The second line of each test case contains three integers a1,a2,a3a_1, a_2, a_3 (0≤ai≤n0 \le a_i \le n), where aia_i is the number of participants who solved problem ii.

第一行包含一个整数 tt(1≤t≤30001 \le t \le 3000)—— 测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤91 \le n \le 9)—— 参赛者人数。

每个测试用例的第二行包含三个整数 a1,a2,a3a_1, a_2, a_3(0≤ai≤n0 \le a_i \le n),其中 aia_i 表示解决第 ii 道题的参赛者人数。

输出格式

For each test case, print a single integer — the minimum possible number of weak participants.

对于每个测试用例,输出一个整数——弱参与者数量的最小可能值。

输入输出样例

  • 输入#1

    6
    3
    3 3 3
    4
    4 4 3
    1
    1 1 1
    9
    9 8 9
    5
    0 5 5
    6
    4 3 2

    输出#1

    0
    1
    0
    1
    5
    4

说明/提示

In the first test case, all 33 participants can have solved all three problems, so the answer is 00.

In the second test case, participant 11 could have solved only problems 11 and 22, while participants 22, 33, and 44 solved all three problems. Therefore, participant 11 is the only participant who is weak, so the answer is 11. It can be shown that this is minimal.

在第一个测试用例中,所有 33 名参与者都可以解出全部三道题目,因此答案为 00。

在第二个测试用例中,参与者 11 可能仅解出了题目 11 和 22,而参与者 22、33 和 44 解出了全部三道题目。因此,参与者 11 是唯一一名弱参与者,答案为 11。可以证明这是最小值。

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

首页