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:

  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.

题接:题目描述的意思就是 x个a y个b, z个c ,在a和b中至少选择一个,最终凑成3个数,c有选不选都可以,问,,最多能有多少种选择?

FS: 马虎,,,下次做这种多中过程的题目时,可以把每个过程的做法以及思路写下来。

思路: 因为z可有可无,所以我们首先要考虑z,如果z比x或者y任何一个数大的话,那就直接输出x和y的最小值。否则优先使用z即答案ans+=z,然后x和y的个数都减去个z,在考虑x和y较大的那个,求差y1,如果y>x和y最小值;

那么输出abs+=x和y的最小值,否则 用掉y  这时x=y=x-y1,,答案为ans+=(x+x)/3'

#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
int x1=min(x,y);
int x2=max(x,y);
if(x1<=z) printf("%d\n",x1);
else {
int ans=;
ans=z;
x1=x1-z;
x2=x2-z;
int y;
y=x2-x1;
if(y>=x1) cout<<x1+ans<<endl;
else {
ans+=y;
x1-=y;
cout<<ans+(x1+x1)/<<endl;
}
}
}
return ;
}

codeforces 122C perfect team的更多相关文章

  1. Codeforces 1221C. Perfect Team

    传送门 考虑如何保证限制,首先团队数最大就是 $min(c,m)$ 但是还不够,每个团队还要 $3$ 个人,所以还要和 $(c+m+x)/3$ 再取 $min$ 这样就满足所有限制了 #include ...

  2. Educational Codeforces Round 73 (Rated for Div. 2) C. Perfect Team

    链接: https://codeforces.com/contest/1221/problem/C 题意: You may have already known that a standard ICP ...

  3. Codeforces 986D Perfect Encoding FFT 分治 高精度

    原文链接https://www.cnblogs.com/zhouzhendong/p/9161557.html 题目传送门 - Codeforces 986D 题意 给定一个数 $n(n\leq 10 ...

  4. Codeforces 980D Perfect Groups 计数

    原文链接https://www.cnblogs.com/zhouzhendong/p/9074164.html 题目传送门 - Codeforces 980D 题意 $\rm Codeforces$ ...

  5. [CodeForces - 919B] Perfect Number

    题目链接:http://codeforces.com/problemset/problem/919/B AC代码: #include<cstdio> using namespace std ...

  6. Codeforces 948D Perfect Security(字典树)

    题目链接:Perfect Security 题意:给出N个数代表密码,再给出N个数代表key.现在要将key组排序,使key组和密码组的亦或所形成的组字典序最小. 题解:要使密码组里面每个数都找到能使 ...

  7. Codeforces 932 E. Team Work(组合数学)

    http://codeforces.com/contest/932/problem/E 题意:   可以看做 有n种小球,每种小球有无限个,先从中选出x种,再在这x种小球中任选k个小球的方案数 选出的 ...

  8. Codeforces 932.E Team Work

    E. Team Work time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  9. CodeForces - 233A Perfect Permutation

    A. Perfect Permutation time limit per test: 2 seconds memory limit per test: 256 megabytes input: st ...

随机推荐

  1. 拜托,别再问我什么是 B+ 树了

    前言 每当我们执行某个 SQL 发现很慢时,都会下意识地反应是否加了索引,那么大家是否有想过加了索引为啥会使数据查找更快呢,索引的底层一般又是用什么结构存储的呢,相信大家看了标题已经有答案了,没错!B ...

  2. 解决 Mac Android Studio Gradle Sync 慢的问题

    1.启动Android Studio 2.从项目的 gradle/wrapper/gradle-wrapper.properties 目录中找到 distributionUrl 这个字段,查看后面对应 ...

  3. 常见排序算法总结分析之选择排序与归并排序-C#实现

    本篇文章对选择排序中的简单选择排序与堆排序,以及常用的归并排序做一个总结分析. 常见排序算法总结分析之交换排序与插入排序-C#实现是排序算法总结系列的首篇文章,包含了一些概念的介绍以及交换排序(冒泡与 ...

  4. C# 基础知识系列- 6 Lambda表达式和Linq简单介绍

    前言 C#的lambda和Linq可以说是一大亮点,C#的Lambda无处不在,Linq在数据查询上也有着举足轻重的地位. 那么什么是Linq呢,Linq是 Language Intergrated ...

  5. Jmeter4.0之插件安装(三)

    使用Jmeter的实际过程中,需要使用到很多插件,比如json的插件,还有就是做websocket接口测试的时候需要下载websocket的插件 到https://jmeter-plugins.org ...

  6. coding++ :Layui-监听事件

    在使用layui的form表单做验证提交的时候,如果结合vue,或者是三级联动的时候,就需要做事件监听了. 具体语法: form.on('event(过滤器值)', callback); 可以用于监听 ...

  7. Redis 集群--------Redis-cluster

    1集群方案 1.官方方案redis-cluster搭建实战 2.客户端分片技术(不推荐),扩容/缩容时,必须手动调整分片程序,出现故障不能自动转移 3.可以使用主从复制方式(不推荐) 4.使用一些代理 ...

  8. 开源APP

    仿微信 https://github.com/zhengwenming/WeChat 电台韵律 https://github.com/DaMingShen 运动App https://github.c ...

  9. 面试中常问的五种IO模型和BIO,NIO,AIO

    一,五种IO模型: 一个IO操作可以分为两个步骤:发起IO请求和实际的IO操作例如:1.操作系统的一次写操作分为两步:第一步,将数据从用户空间拷贝到系统空间:第二步,从系统空间往网卡写.2.一次读操作 ...

  10. JS烟花案例优化版

    不明白为什么是烟花优化版本的先参考作者的烟花基础版本 烟花优化版本主要实在优化爆炸的范围和运动上做了优化,爆炸范围我们采用已圆的爆炸方式,以鼠标点击的位置为圆形爆炸的烟花效果 <!DOCTYPE ...