A12943 | Perfect Team
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $c$ of your students are coders, $m$ are mathematicians and $x$ 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 $q$ independent queries.
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 $c$ of your students are coders, $m$ are mathematicians and $x$ 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 $q$ independent queries.
输入格式
The first line contains a single integer $q$ ( $1 \le q \le 10^4$ ) — the number of queries.
Each of the next $q$ lines contains three integers $c$ , $m$ and $x$ ( $0 \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.
Each of the next $q$ lines contains three integers $c$ , $m$ and $x$ ( $0 \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.
输出格式
Print $q$ integers — the $i$ -th of them should be the answer to the $i$ 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.
输入输出样例
输入 #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. 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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted