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 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.
思路:
将c, m变成min(c, m), 多的加到x中, 先得到min(c, x),如果x大, 那么答案不可能用x剩下的组合.
如果c大, 因为剩下的c=m所以可以继续使用.
或者不改变直接二分判断答案也可以
代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t, a, b, c;
cin >> t;
while (t--)
{
cin >> a >> b >> c;
if (a < b)
swap(a, b);
c += (a-b);
a = b;
int sum = min(a, c);
a -= sum, b -= sum, c -= sum;
cout << sum+(a+b)/3 << endl;
}
return 0;
}
最新文章
- 输入三个数a,b,c,要示按由小到大的顺序输出
- MySQL 5.6 my.cnf 模版
- programing Python --Sys module
- Objective-C运行时编程 - 方法混写 Method Swizzling
- mutable和volatile关键字
- [itint5]棋盘漫步
- 将FAT32格式转换成NTFS格式命令
- web项目跨域访问
- CSS垂直翻转与水平翻转
- /*+ hint*/用法,该如何解决
- 【Ray Tracing The Next Week 超详解】 光线追踪2-6 Cornell box
- js 引擎 和 html 渲染引擎
- sql 导入导出表数据 命令
- ArcGIS Pro 切割打印
- 【leetcode 简单】 第七十三题 丑数
- C#剪切板
- 垃圾收集(GC)中如何确定哪些内存是";垃圾
- Linux 系统使用 iso 镜像文件或光盘配置本地YUM 源的最简单方式
- 修改 Input placeholder 的样式
- vim之vundle