C. A and B and Team Training
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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?

Input

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.

Output

Print the maximum number of teams that can be formed.

Sample test(s)
Input
2 6
Output
2
Input
4 5
Output
3
Note

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 水题的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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: ...

  4. 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 ...

  5. 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.直接暴力判断即 ...

  6. Codeforces Round #294 (Div. 2) D. A and B and Interesting Substrings

    题意: 对于26个字母 每个字母分别有一个权值 给出一个字符串,找出有多少个满足条件的子串, 条件:1.第一个字母和最后一个相同,2.除了第一个和最后一个字母外,其他的权和为0 思路: 预处理出sum ...

  7. Codeforces Round #294 (Div. 2)

    水 A. A and B and Chess /* 水题 */ #include <cstdio> #include <algorithm> #include <iost ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. aarch64_m3

    mrpt-stereo-camera-calibration-1.4.0-1.fc26.aarch64.rpm 2017-03-17 10:02 143K fedora Mirroring Proje ...

  2. getattr的使用

    from requests_html import HTMLSession class UrlGenerator(object): def __init__(self, root_url): self ...

  3. kettle简单插入与更新

    Kettle简介:Kettle是一款国外开源的ETL工具,纯java编写,可以在Window.Linux.Unix上运行,数据抽取高效稳定.Kettle 中文名称叫水壶,该项目的主程序员MATT 希望 ...

  4. vs2012 连接oracle11g 及数据的insert及select 的总结

    下载链接Oracle 11g所需的驱动ODTwithODAC1120320_32bit,下载链接为http://www.oracle.com/technetwork/topics/dotnet/uti ...

  5. 003_ElasticSearch详解与优化设计

    简介 概念 安装部署 ES安装 数据索引 索引优化 内存优化 1简介 ElasticSearch(简称ES)是一个分布式.Restful的搜索及分析服务器,设计用于分布式计算:能够达到实时搜索,稳定, ...

  6. 08 Packages 包

    Packages   Standard library Other packages Sub-repositories Community Standard library Name Synopsis ...

  7. java基础61 JavaScript循环语句之while、do...while、for及for...in循环(网页知识)

    本文知识点(目录): 1.while循环语句    2.do...while循环语句    3.for循环语句    4.for...in循环语句    5.附录1(with语句)    6.附录2( ...

  8. 错误/异常:The project cannot be built until build path errors are resolved 和 Unbound classpath container: 'JRE System Library [JavaSE-1.7]' in project 'MyJavaCode';的解决方法

    错误1: The project cannot be built until build path errors are resolved 解决方法: 把java的类库加载进去即可,在工程上右键 选择 ...

  9. git —— 基本命令以及操作(No.1)

    git基本命令(附加描述) 1.把文件添加到暂存区$ git add readme.txt 2.把暂存区的文件文件添加到仓库$ git commit -m "提交说明" 备注:ad ...

  10. LCT解读(1)

    蒟蒻的LCT解读(1) 前段时间本蒟蒻自学了一下LCT,但是网上的很多资料并不很全,而且作为一个数组选手,我看指针代码真的很麻烦,所以就在这里写一篇数组选手能看懂的代码. LCT的初步了解 LCT全称 ...