CF1221C.Perfect Team

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You may have already known that a standard ICPC team consists of exactly three members. The perfect team however has more restrictions. A student can have some specialization: coder or mathematician. She/he can have no specialization, but can't have both at the same time.

So the team is considered perfect if it includes at least one coder, at least one mathematician and it consists of exactly three members.

You are a coach at a very large university and you know that cc of your students are coders, mm are mathematicians and xx have no specialization.

What is the maximum number of full perfect teams you can distribute them into?

Note that some students can be left without a team and each student can be a part of no more than one team.

You are also asked to answer qq independent queries.

你可能已经知道,一个标准的 ICPC 队伍恰好由三名成员组成。然而,“完美队伍”还有更多限制条件。每名学生可以具有一种专长:程序员(coder)或数学家(mathematician);也可以没有任何专长,但不能同时具备两种专长。

因此,一支队伍被称为“完美队伍”,当且仅当它至少包含一名程序员、至少一名数学家,且恰好由三名成员组成。

你是一所大型大学的教练,已知你的学生中有 cc 名程序员、mm 名数学家、xx 名没有任何专长的学生。

你最多能组成多少支完整的完美队伍?

注意:部分学生可能无法加入任何队伍,且每名学生至多只能属于一支队伍。

你还需要回答 qq 个相互独立的查询。

输入格式

The first line contains a single integer qq (1≤q≤1041 \le q \le 10^4) — the number of queries.

Each of the next qq lines contains three integers cc, mm and xx (0≤c,m,x≤1080 \le c, m, x \le 10^8) — the number of coders, mathematicians and students without any specialization in the university, respectively.

Note that the no student is both coder and mathematician at the same time.

第一行包含一个整数 qq(1≤q≤1041 \le q \le 10^4),表示查询次数。

接下来的 qq 行,每行包含三个整数 cc、mm 和 xx(0≤c,m,x≤1080 \le c, m, x \le 10^8),分别表示大学中程序员、数学家以及无任何专业方向的学生人数。

注意:没有任何学生同时是程序员和数学家。

输出格式

Print qq integers — the ii-th of them should be the answer to the ii query in the order they are given in the input. The answer is the maximum number of full perfect teams you can distribute your students into.

输出 qq 个整数——其中第 ii 个整数应为输入中第 ii 个查询的答案(按输入顺序)。答案是你能将学生分配成的完整且完美的团队的最大数目。

输入输出样例

  • 输入#1

    6
    1 1 1
    3 6 0
    0 0 0
    0 1 1
    10 1 10
    4 4 1

    输出#1

    1
    3
    0
    0
    1
    3

说明/提示

In the first example here are how teams are formed:

  1. the only team of 1 coder, 1 mathematician and 1 without specialization;
  2. all three teams consist of 1 coder and 2 mathematicians;
  3. no teams can be formed;
  4. no teams can be formed;
  5. one team consists of 1 coder, 1 mathematician and 1 without specialization, the rest aren't able to form any team;
  6. one team consists of 1 coder, 1 mathematician and 1 without specialization, one consists of 2 coders and 1 mathematician and one consists of 1 coder and 2 mathematicians.

在第一个示例中,队伍的组成方式如下:

  1. 唯一的一支队伍由 1 名程序员、1 名数学家和 1 名无专长者组成;
  2. 所有三支队伍均由 1 名程序员和 2 名数学家组成;
  3. 无法组成任何队伍;
  4. 无法组成任何队伍;
  5. 一支队伍由 1 名程序员、1 名数学家和 1 名无专长者组成,其余人员无法组成任何队伍;
  6. 一支队伍由 1 名程序员、1 名数学家和 1 名无专长者组成,一支由 2 名程序员和 1 名数学家组成,一支由 1 名程序员和 2 名数学家组成。

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

首页