Codeforces Round #294 (Div. 2)C - A and B and Team Training 水题
1 second
256 megabytes
standard input
standard output
A and B are preparing themselves for programming contests.
An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams so that newbies are solving problems together with experienced participants.
A believes that the optimal team of three people should consist of one experienced participant and two newbies. Thus, each experienced participant can share the experience with a large number of people.
However, B believes that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.
As a result, A and B have decided that all the teams during the training session should belong to one of the two types described above. Furthermore, they agree that the total number of teams should be as much as possible.
There are n experienced members and m newbies on the training session. Can you calculate what maximum number of teams can be formed?
The first line contains two integers n and m (0 ≤ n, m ≤ 5·105) — the number of experienced participants and newbies that are present at the training session.
Print the maximum number of teams that can be formed.
2 6
2
4 5
3
Let's represent the experienced players as XP and newbies as NB.
In the first test the teams look as follows: (XP, NB, NB), (XP, NB, NB).
In the second test sample the teams look as follows: (XP, NB, NB), (XP, NB, NB), (XP, XP, NB).
题意:给你N个A类人和M个B类人
他们可以组队,组队方式有两种,2个A和一个B,2个B和一个A这样子组队
然后问你最多可以组多少对
题解:暴力模拟组队就好了……每次选择少的那类人派出一个人就好
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 100001
#define eps 1e-9
const int inf=0x7fffffff; //无限大
int main()
{
int ans=;
int n,m;
cin>>n>>m;
while()
{
if(n<&&m<||n==||m==)
break;
if(n<m)
{
n-=;
m-=;
ans++;
}
else
{
m-=;
n-=;
ans++;
}
}
cout<<ans<<endl;
}
Codeforces Round #294 (Div. 2)C - A and B and Team Training 水题的更多相关文章
- Codeforces Round #294 (Div. 2)B - A and B and Compilation Errors 水题
B. A and B and Compilation Errors time limit per test 2 seconds memory limit per test 256 megabytes ...
- Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones 水题
A. Case of the Zeros and Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...
- Codeforces Round #624 (Div. 3) A. Add Odd or Subtract Even(水题)
You are given two positive integers aa and bb . In one move, you can change aa in the following way: ...
- Codeforces Round #267 (Div. 2) C. George and Job(DP)补题
Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently ...
- Codeforces Round #430 (Div. 2) 【A、B、C、D题】
[感谢牛老板对D题的指点OTZ] codeforces 842 A. Kirill And The Game[暴力] 给定a的范围[l,r],b的范围[x,y],问是否存在a/b等于k.直接暴力判断即 ...
- Codeforces Round #294 (Div. 2) D. A and B and Interesting Substrings
题意: 对于26个字母 每个字母分别有一个权值 给出一个字符串,找出有多少个满足条件的子串, 条件:1.第一个字母和最后一个相同,2.除了第一个和最后一个字母外,其他的权和为0 思路: 预处理出sum ...
- Codeforces Round #294 (Div. 2)
水 A. A and B and Chess /* 水题 */ #include <cstdio> #include <algorithm> #include <iost ...
- Codeforces Round #294 (Div. 2)D - A and B and Interesting Substrings 字符串
D. A and B and Interesting Substrings time limit per test 2 seconds memory limit per test 256 megaby ...
- Codeforces Round #294 (Div. 2)A - A and B and Chess 水题
A. A and B and Chess time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- Tslib的移植【转】
转自:http://www.cnblogs.com/uvsjoh/archive/2011/08/25/2152947.html移植Tslib 1 下载源码tslib-x.x.tar.gz 2 解压, ...
- 2018 ICPC 徐州网络赛
2018 ICPC 徐州网络赛 A. Hard to prepare 题目描述:\(n\)个数围成一个环,每个数是\(0\)~\(2^k-1\),相邻两个数的同或值不为零,问方案数. solution ...
- 七、springcloud之配置中心Config(二)之高可用集群
方案一:传统作法(不推荐) 服务端负载均衡 将所有的Config Server都指向同一个Git仓库,这样所有的配置内容就通过统一的共享文件系统来维护,而客户端在指定Config Server位置时, ...
- scala中“_”的用法
参见链接 http://blog.csdn.net/i6448038/article/details/50017427
- java基础20 StringBuffer缓冲类
1.概要 StringBuffer 其实就是一个存储字符的容器 字符串特点:字符串是常量;它们创建之后不能更改了字符串一旦发生变化,那么立马创建一个新的对象.注意:字符串的内容不适合频繁修改的,因为一 ...
- ubuntu 创建容器 并ssh 连接容器
1.下载镜像:docker search ubuntu docker pull ubuntu 2. 创建容器 docker run --name spider_frame -p 8888:8888 - ...
- 云计算IaaS浅谈
(本篇文章仅仅是整理文档资料时,发现的一篇课程报告,感觉还挺有参考意义的) 最近几年云计算一直是IT业的热点,一股炽热的云计算浪潮席卷了世界,全世界都在讲云计算,都在搞云计算.虽然最初是由谷歌公司提出 ...
- HDU 2609 How many(最小表示+set)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2609 题目大意: 题目大意有n个有01组成的字符串,每个字符串都代表一个项链,那么该字符串就是一个环状 ...
- Temp权限导致Win10安装程序失败提示2502/2503错误
有Win10用户在安装程序时遇到了安装失败错误代码2502/2503的问题.如图: 其原因是Windows Installer安装程序需要当前用户具有C:\Windows\Temp目录的完全控制权限, ...
- 【POJ】1704.Georgia and Bob
题解 感觉挺神奇的 我们把石子从后往前相邻的两个两两配对,这样他们之间的空格就相当于一堆石子 而配对后左边棋子移动,右边棋子也一定可以跟上取 转化成简单的nim游戏,最后只要看转化出的这(N - 1) ...