CF1250L.Divide The Students

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

A group of students has recently been admitted to the Faculty of Computer Sciences at the Berland State University. Now the programming teacher wants to divide them into three subgroups for practice sessions.

The teacher knows that a lot of programmers argue which language is the best. The teacher doesn't want to hear any arguments in the subgroups, so she wants to divide the students into three subgroups so that no pair of students belonging to the same subgroup want to argue.

To perform this division, the teacher asked each student which programming language he likes. There are aa students who answered that they enjoy Assembler, bb students stated that their favourite language is Basic, and cc remaining students claimed that C++ is the best programming language — and there was a large argument between Assembler fans and C++ fans.

Now, knowing that Assembler programmers and C++ programmers can start an argument every minute, the teacher wants to divide the students into three subgroups so that every student belongs to exactly one subgroup, and there is no subgroup that contains at least one Assembler fan and at least one C++ fan. Since teaching a lot of students can be difficult, the teacher wants the size of the largest subgroup to be minimum possible.

Please help the teacher to calculate the minimum possible size of the largest subgroup!

一群学生最近被录取进入贝尔兰国立大学计算机科学学院。现在,编程教师希望将他们分为三个小组进行实践课程。

教师知道,许多程序员会争论哪种编程语言最好。为避免小组内出现任何争论,教师希望将学生划分为三个小组,使得同一小组中任意两名学生之间都不会发生争论。

为完成这一划分,教师询问了每名学生各自喜欢的编程语言。其中,有 aa 名学生回答自己喜欢汇编语言(Assembler),bb 名学生表示自己最钟爱 BASIC 语言,其余 cc 名学生则声称 C++ 是最佳编程语言——而汇编语言爱好者与 C++ 爱好者之间曾爆发过一场激烈争论。

现已知汇编语言程序员与 C++ 程序员每分钟都可能引发一场争论,因此教师希望将学生划分为三个小组,使得每名学生恰好属于一个小组,且任意一个小组中均不能同时包含至少一名汇编语言爱好者和至少一名 C++ 爱好者。由于教授大量学生难度较大,教师希望使最大小组的规模尽可能小。

请帮助教师计算最大小组的最小可能规模!

输入格式

The first line contains one integer tt (1≤t≤51 \le t \le 5) — the number of test cases in the input. Then test cases follow.

Each test case consists of one line containing three integers aa, bb and cc (1≤a,b,c≤10001 \le a, b, c \le 1000) — the number of Assembler fans, Basic fans and C++ fans, respectively.

第一行包含一个整数 tt(1≤t≤51 \le t \le 5)—— 表示输入中测试用例的数量。随后是各测试用例。

每个测试用例由一行组成,包含三个整数 aa、bb 和 cc(1≤a,b,c≤10001 \le a, b, c \le 1000)—— 分别表示汇编语言(Assembler)粉丝、Basic 语言粉丝和 C++ 语言粉丝的人数。

输出格式

For each test case print one integer — the minimum size of the largest subgroup if the students are divided in such a way that there is no subgroup that contains at least one Assembler fan and at least one C++ fan simultaneously.

对于每个测试用例,输出一个整数——即在将学生分组时,使得不存在任何一个子组同时包含至少一名汇编语言(Assembler)爱好者和至少一名 C++ 爱好者的情况下,最大子组的最小可能大小。

输入输出样例

  • 输入#1

    5
    3 5 7
    4 8 4
    13 10 13
    1000 1000 1000
    13 22 7

    输出#1

    5
    6
    13
    1000
    14
  • 输入#2

    5
    1 3 4
    1000 1000 1
    4 1 2
    325 226 999
    939 861 505

    输出#2

    3
    667
    3
    517
    769

说明/提示

Explanation of the answers for the example 11:

  1. The first subgroup contains 33 Assembler fans and 22 Basic fans, the second subgroup — 55 C++ fans, the third subgroup — 22 C++ fans and 33 Basic fans.
  2. The first subgroup contains 44 Assembler fans, the second subgroup — 66 Basic fans, the third subgroup — 22 Basic fans and 44 C++ fans.
  3. The first subgroup contains all Assembler fans, the second subgroup — all Basic fans, the third subgroup — all C++ fans.
  4. The first subgroup contains all Assembler fans, the second subgroup — all Basic fans, the third subgroup — all C++ fans.
  5. The first subgroup contains 1212 Assembler fans and 22 Basic fans, the second subgroup — 11 Assembler fan and 1313 Basic fans, the third subgroup — 77 Basic fans and 77 C++ fans.

示例 11 的答案解释:

  1. 第一个子组包含 33 名汇编语言爱好者和 22 名 Basic 爱好者,第二个子组包含 55 名 C++ 爱好者,第三个子组包含 22 名 C++ 爱好者和 33 名 Basic 爱好者。
  2. 第一个子组包含 44 名汇编语言爱好者,第二个子组包含 66 名 Basic 爱好者,第三个子组包含 22 名 Basic 爱好者和 44 名 C++ 爱好者。
  3. 第一个子组包含全部汇编语言爱好者,第二个子组包含全部 Basic 爱好者,第三个子组包含全部 C++ 爱好者。
  4. 第一个子组包含全部汇编语言爱好者,第二个子组包含全部 Basic 爱好者,第三个子组包含全部 C++ 爱好者。
  5. 第一个子组包含 1212 名汇编语言爱好者和 22 名 Basic 爱好者,第二个子组包含 11 名汇编语言爱好者和 1313 名 Basic 爱好者,第三个子组包含 77 名 Basic 爱好者和 77 名 C++ 爱好者。

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

首页