博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Perfect Team CodeForces - 1221C(二分)
阅读量:4135 次
发布时间:2019-05-25

本文共 2229 字,大约阅读时间需要 7 分钟。

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.

Input

The first line contains a single integer qq (1≤q≤1041≤q≤104) — the number of queries.

Each of the next qq lines contains three integers cc, mm and xx (0≤c,m,x≤1080≤c,m,x≤108) — 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.

Output

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.

Example

Input
6
1 1 1
3 6 0
0 0 0
0 1 1
10 1 10
4 4 1
Output
1
3
0
0
1
3
Note
In the first example here are how teams are formed:

the only team of 1 coder, 1 mathematician and 1 without specialization;

all three teams consist of 1 coder and 2 mathematicians;
no teams can be formed;
no teams can be formed;
one team consists of 1 coder, 1 mathematician and 1 without specialization, the rest aren’t able to form any team;
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.
裸的二分题。二分答案,判断能否组成。
代码如下:

#include
#define ll long longusing namespace std;ll a,b,c;inline bool check(ll x){
if(a
>1; if(check(mid)) {
ans=mid; l=mid+1; } else r=mid-1; } cout<
<

努力加油a啊,(o)/~

转载地址:http://kftvi.baihongyu.com/

你可能感兴趣的文章
苹果自研 M1 芯片性能强大,却不支持 Docker ?
查看>>
漫画 | 前端发展史的江湖恩怨情仇~
查看>>
2020年12月程序员工资统计,平均14222元(转载)
查看>>
推荐几个好用又好玩的vscode插件!(转载)
查看>>
对标鸿蒙 OS,Google 下一代操作系统 Fuchsia 源码公开!(转载)
查看>>
15 个优秀开源的 Spring Boot 学习项目,一网打尽!(转载)
查看>>
AI 版 Nature Index 排名,两种结果折射中国 AI 实力软肋(转载)
查看>>
一文带你轻松掌握多种编程范式(转载)
查看>>
GitHub标星7000+,快速恢复像素化图像,效果惊人(转载)
查看>>
一分钟将Vue移动端项目一键打包成app(转载)
查看>>
推荐几个好用又好玩的vscode插件!(转载)
查看>>
太厉害了,终于有人能把TCP/IP 协议讲的明明白白了(转载)
查看>>
Linux入门 一篇就够了
查看>>
2021年2月程序员工资统计,平均15144元
查看>>
基于Python的OpenCV人脸检测
查看>>
提取视频中的音频——python三行程序搞定
查看>>
Flutter项目在 iOS14 启动崩溃
查看>>
DevEco Studio 2.0开发鸿蒙HarmonyOS应用初体验全面测评
查看>>
WordPress网站访问慢解决方案(超详细图文教程)
查看>>
太厉害了,终于有人能把TCP/IP 协议讲的明明白白了
查看>>