CF2266A.Good Contest
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The next programming contest has three problems and n participants.
Problem 1 is easy, problem 2 is medium, and problem 3 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 a of length 3, where ai is the number of participants who solved problem i.
Among all scoreboards consistent with this information, find the minimum possible number of weak participants.
下一届编程竞赛共有三道题目和 n 名参赛者。
第 1 题简单,第 2 题中等,第 3 题困难。
若一名参赛者未解出全部三道题目,则称其为“弱参赛者”。
不幸的是,记分板丢失了。目前仅剩一个长度为 3 的数组 a,其中 ai 表示解出第 i 题的参赛者人数。
在所有与该信息一致的记分板中,求弱参赛者的最少可能人数。
输入格式
The first line contains an integer t (1≤t≤3000) — the number of test cases.
The first line of each test case contains an integer n (1≤n≤9) — the number of participants.
The second line of each test case contains three integers a1,a2,a3 (0≤ai≤n), where ai is the number of participants who solved problem i.
第一行包含一个整数 t(1≤t≤3000)—— 测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤9)—— 参赛者人数。
每个测试用例的第二行包含三个整数 a1,a2,a3(0≤ai≤n),其中 ai 表示解决第 i 道题的参赛者人数。
输出格式
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 3 participants can have solved all three problems, so the answer is 0.
In the second test case, participant 1 could have solved only problems 1 and 2, while participants 2, 3, and 4 solved all three problems. Therefore, participant 1 is the only participant who is weak, so the answer is 1. It can be shown that this is minimal.
在第一个测试用例中,所有 3 名参与者都可以解出全部三道题目,因此答案为 0。
在第二个测试用例中,参与者 1 可能仅解出了题目 1 和 2,而参与者 2、3 和 4 解出了全部三道题目。因此,参与者 1 是唯一一名弱参与者,答案为 1。可以证明这是最小值。
输入解题思路,AI测评打分。不知道怎么写?