codeforces 122C perfect team
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
6
1 1 1
3 6 0
0 0 0
0 1 1
10 1 10
4 4 1
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.
题接:题目描述的意思就是 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的更多相关文章
- Codeforces 1221C. Perfect Team
传送门 考虑如何保证限制,首先团队数最大就是 $min(c,m)$ 但是还不够,每个团队还要 $3$ 个人,所以还要和 $(c+m+x)/3$ 再取 $min$ 这样就满足所有限制了 #include ...
- 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 ...
- Codeforces 986D Perfect Encoding FFT 分治 高精度
原文链接https://www.cnblogs.com/zhouzhendong/p/9161557.html 题目传送门 - Codeforces 986D 题意 给定一个数 $n(n\leq 10 ...
- Codeforces 980D Perfect Groups 计数
原文链接https://www.cnblogs.com/zhouzhendong/p/9074164.html 题目传送门 - Codeforces 980D 题意 $\rm Codeforces$ ...
- [CodeForces - 919B] Perfect Number
题目链接:http://codeforces.com/problemset/problem/919/B AC代码: #include<cstdio> using namespace std ...
- Codeforces 948D Perfect Security(字典树)
题目链接:Perfect Security 题意:给出N个数代表密码,再给出N个数代表key.现在要将key组排序,使key组和密码组的亦或所形成的组字典序最小. 题解:要使密码组里面每个数都找到能使 ...
- Codeforces 932 E. Team Work(组合数学)
http://codeforces.com/contest/932/problem/E 题意: 可以看做 有n种小球,每种小球有无限个,先从中选出x种,再在这x种小球中任选k个小球的方案数 选出的 ...
- Codeforces 932.E Team Work
E. Team Work time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- CodeForces - 233A Perfect Permutation
A. Perfect Permutation time limit per test: 2 seconds memory limit per test: 256 megabytes input: st ...
随机推荐
- 微信小程序分享转发用法大全——自定义分享、全局分享、组合分享
官方提供的自定义分享 使用隐式页面配置函数实现的全局分享-推荐 使用隐式路由实现的全局分享-不推荐,仅供了解隐式路由 前言: 目前微信小程序只开放了页面自定义分享的API,为了能够更灵活的进行分享配置 ...
- eureka和zookeeper注册中心的区别
ookeeper与Eureka区别 CPA理论:一个分布式系统不可能同时满足C(一致性).A(可用性)和P(分区容错性).由于分区容错性在是分布式系统中必须要保证的,因此我们只能在A和C之间进行权衡. ...
- 使用tensorflow实现cnn进行mnist识别
第一个CNN代码,暂时对于CNN的BP还不熟悉.但是通过这个代码对于tensorflow的运行机制有了初步的理解 ''' softmax classifier for mnist created on ...
- AI学习笔记:特征工程
一.概述 Andrew Ng:Coming up with features is difficult, time-consuming, requires expert knowledge. &quo ...
- ATM购物车+三层结构项目设计
ATM购物车项目 模拟实现一个ATM + 购物商城程序. 该程序实现普通用户的登录注册.提现充值还款等功能,并且支持到网上商城购物的功能. 账户余额足够支付商品价格时,扣款支付:余额不足时,无法支付, ...
- Java 运行时数据区
写在前面 本文描述的有关于 JVM 的运行时数据区是基于 HotSpot 虚拟机. 概述 JVM 在执行 Java 程序的过程中会把它所管理的内存划分为若干个不同的数据区域.这些区域都有各自的用途,以 ...
- SpringBoot整合Springfox-Swagger2
前言 不管Spring Boot整合还是SpringMVC整合Swagger都基本类似,重点就在于配置Swagger,它的精髓所在就在于配置. @ 目录 1.Swagger简介 2.整合前可能遇到的问 ...
- new FileReader()
一.调用FileReader对象的方法 方法名 参数 描述abort none 中断读取readAsBinaryString file 将文件读取为二进制码readAsDataURL file 将文件 ...
- 使用mpvue开发小程序如何定义全局变量
我们创建好mpvue项目之后,找到src/main.js打开在后面添加一行代码 (注意:不能在const app = new Vue(App) 之前添加) Vue.prototype.globalDa ...
- 搭建 sqli SQL注入练习靶场
文章更新于:2020-02-18 按照惯例,需要的文件附上链接放在文首 文件名:sqli-labs-master.zip 文件大小:3.5 M 下载链接:https://www.lanzous.com ...