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 ...
随机推荐
- linux查看内存、CPU占用资源最多的进程
[内存占用] #利用ps命令,默认使用ps参数会显示的结果 ps -aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 ...
- SQLAlchemy-对象关系教程ORM-create
ORM是建立在SQL语言构造器之上的工具集,用于将Python对象映射到数据库的行,提供了一系列接口用于从数据库中存取对象(行).在ORM 工作时,在底层调用SQL语言构造器的API,这些通用的操作有 ...
- 移动端Touch事件
案例1: <!doctype html> <html lang="en"> <head> <meta charset="UTF- ...
- centos7.2下caffe的安装及编译
1.前期准备 安装依赖 sudo yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5 ...
- SQL SERVER中查询某个表或某个索引是否存在
查询某个表是否存在: 在实际应用中可能需要删除某个表,在删除之前最好先判断一下此表是否存在,以防止返回错误信息.在SQL SERVER中可通过以下语句实现: IF OBJECT_ID(N'表名称', ...
- HBase入门笔记--读性能优化
一.前言 在生产环境使用HBase过程中,随着数据量的不断增加,查询HBase数据变得越来越慢,对于业务来说是不可用的,需要对读性能进行优化 二.问题定位 从hbase监控指标来看,发现FullGC次 ...
- **CodeIgniter-cURL扩展
Work with cURL easily from your CodeIgniter application. Tweet Contributor : philsturgeon Email : Lo ...
- **PHP转义Json里的特殊字符的函数
http://www.banghui.org/11332.html 在给一个 App 做 API,从服务器端的 MySQL 取出数据,然后生成 JSON.数据中有个字段叫 content,里面保存了文 ...
- Metronic4.7.5 下载 HTML5 UI后台管理框架
Metronic 是一套精美的响应式后台管理模板,基于强大的 Twitter Bootstrap 3.3.4 框架实现.Metronic 拥有简洁优雅的 Metro UI 风格界面,6 种颜色可选,7 ...
- 【AtCoder】AGC011 E - Increasing Numbers
题解 题是真的好,我是真的不会做 智商本还是要多开啊QwQ 我们发现一个非下降的数字一定可以用不超过九个1111111111...1111表示 那么我们可以得到这样的一个式子,假如我们用了k个数,那么 ...