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

存在两种情况,要么两个高手带一个新手,要么一个高手带两个新手。

很简单的。

 #include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cctype>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#define LL long long
#define PF(x) ((x)*(x))
#define LF(x) ((x)*PF(x)) using namespace std;
const int INF=<<-;
const int max9=1e9;
const int max6=1e6;
const int max3=1e3; int gcd(int a,int b)
{
return b==?a:gcd(b,a%b);
} int main()
{
int n,m;
while(cin >> n >> m)
{
int Ans=(n+m)/;
Ans=min(Ans,n);
Ans=min(Ans,m);
cout << Ans << endl;
}
return ;
}

codeforces 519C.. A and B and Team Training的更多相关文章

  1. codeforces 519C. A and B and Team Training 解题报告

    题目链接:http://codeforces.com/contest/519/problem/C 题目意思:给出 n 个  experienced participants  和 m 个 newbie ...

  2. Codeforces Round #294 (Div. 2)C - A and B and Team Training 水题

    C. A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input ...

  3. CF A and B and Team Training (数学)

    A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input sta ...

  4. 294 div2 C. A and B and Team Training

    C. A and B and Team Training 题目:A and B are preparing themselves for programming contests. An import ...

  5. codeforces水题100道 第十一题 Codeforces Round #143 (Div. 2) A. Team (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/231/A题意:问n道题目当中有多少道题目是至少两个人会的.C++代码: #include < ...

  6. Codeforces Round #235 (Div. 2) C. Team

    C. Team time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

  7. Codeforces Round #279 (Div. 2) A. Team Olympiad 水题

    #include<stdio.h> #include<iostream> #include<memory.h> #include<math.h> usi ...

  8. cf519C. A and B and Team Training(找规律)

    题意 $a$个学生,$b$个教练 可以两个学生和一个教练一组,也可以两个教练和一个学生一组,问最多组成多少组 Sol 发题解的目的是为了纪念一下自己的错误思路 刚开始想的是:贪心的选,让少的跟多的分在 ...

  9. 【Henu ACM Round#15 C】 A and B and Team Training

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举第一种方法. 剩下的全都个第二种方法. 看看能组成多少个队伍就可以了. [代码] #include <bits/stdc+ ...

随机推荐

  1. [Head First Python]4.读取文件datafile.txt, 去除两边空格, 存储到列表,从列表格式化(nester.py)后输出到文件man.out,other.out

    datafile.txt  #文件 Man: this is the right room for an argument. Other Man: I've told you once. Man: N ...

  2. XML的特殊字符

    XML中共有5个特殊的字符,分别是:&<>“’.如果配置文件中的注入值包括这些特殊字符,就需要进行特别处理.有两种解决方法: 其一,采用本例中的<![CDATA[ ]]> ...

  3. The number of divisors(约数) about Humble Numbers

    The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  4. Hdu1089

    #include <stdio.h> int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF){ p ...

  5. mysql-protocol中对编码长度整数型的规则

    固定长度整型数值在mysql 协议中的应用之一就是affected row :这个要根据首字节来判断 1.如果首字节小于251;那么首字节就是它要表示的数值. 2.如果首字节等于251;那么它表示的就 ...

  6. android fragment 跳到另一个fragment

    一共有4个fragment,分别是contact(联系人),friends(朋友),search(查找),more(更多).使用的都是同一个布局,每个fragment中都有四个内部按钮,可以切换到其他 ...

  7. ISBN-10和ISBN-13有什么区别?

    ISBN扩升至13位 1. 现有ISBN的结构 国际标准书号ISBN是英文International Standard Book Number的缩写,1971年国际标准化组织ISO(Internati ...

  8. plsql在64位机器下读取tnsname.ora 及oracle_home异常的解决办法

    问题是: 我在自己电脑(win7  64bit)上安装了oracle的64位数据库   通过sqlplus能正常连接 主要是安装pl/sql时   我是这样安装的1.在网上下载了个instantcli ...

  9. bzoj1637 [Usaco2007 Mar]Balanced Lineup

    Description Farmer John 决定给他的奶牛们照一张合影,他让 N (1 ≤ N ≤ 50,000) 头奶牛站成一条直线,每头牛都有它的坐标(范围: 0..1,000,000,000 ...

  10. myeclipse集成weblogicserver

    今天为了学一下JMS的东东, 不得不安装个weblogicserver, 下面是详细的安装步骤: 1. 首先去官网下载一个weblogic: 下载地址: http://download.oracle. ...