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. 处理事件的方式:两种类的覆盖处理(自己管理,覆盖专用事件函数;自己统一管理,覆盖QWidget::Event通用函数),一种对象的处理(父控件统一管理,即安装过滤器),两种全局处理(QCoreApplication安装过滤器;覆盖notify方法)

    虽然只有一句话,但却是我自己的心得. 特别注意,bool QCoreApplication::notify(QObject *receiver, QEvent *event) 明确指明了要发送的对象, ...

  2. 常用财务软件:用友,金蝶,新中大,速达,管家婆,金算盘,远方,远光,金钥匙,润衡,浪潮,上海博科,易商,任我行,千方百剂,智管,小蜜蜂,SAP,ORACLE,SSA,QAD,MAPICS,JDE。

    常用财务软件:用友,金蝶,新中大,速达,管家婆,金算盘,远方,远光,金钥匙,润衡,浪潮,上海博科,易商,任我行,千方百剂,智管,小蜜蜂,SAP,ORACLE,SSA,QAD,MAPICS,JDE. 申 ...

  3. linux命令行常用快捷键

    方向          <-前               后 ->删除ctrl + d      删除光标所在位置上的字符相当于VIM里x或者dlctrl + h      删除光标所在 ...

  4. 多个ORACLE HOME的情况,默认的ORACLE HOME是哪个,以及如何更改HOME

    如果系统里安装了多个ORACLE产品,那么在注册表里,有可能也会有多个ORACLE HOME,在不设置系统环境变量的情况下,默认情况使用哪个ORACLE HOME? HKEY_LOCAL_MACHIN ...

  5. cf479E Riding in a Lift

    E. Riding in a Lift time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. UESTC_菲波拉契数制升级版 2015 UESTC Training for Dynamic Programming<Problem L>

    L - 菲波拉契数制升级版 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Su ...

  7. Contains Duplicate 解答

    Question Given an array of integers, find if the array contains any duplicates. Your function should ...

  8. FWA winner | Car Visualizer WebGL

    FWA winner | Car Visualizer WebGL Car Visualizer made in WebGL using ThreeJS. It requires a modern b ...

  9. [Ruby学习总结]Ruby中的类

    1.类名的定义以大写字母开头,单词首字母大写,不用"_"分隔 2.实例化对象的时候调用new方法,实际上调用的是类里边的initialize方法,是ruby类的初始化方法,功能等同 ...

  10. PHP 表单验证 - 必填字段

    -------------------------------------------------------------------------- 本节展示如何制作必填输入字段,并创建需要时所用的错 ...