zoukankan      html  css  js  c++  java
  • codeforces 519C.. 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
    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).

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

    很简单的。

     1 #include<iostream>
     2 #include<algorithm>
     3 #include<cstring>
     4 #include<iomanip>
     5 #include<cctype>
     6 #include<string>
     7 #include<cmath>
     8 #include<cstdio>
     9 #include<cstdlib>
    10 #define LL long long
    11 #define PF(x) ((x)*(x))
    12 #define LF(x) ((x)*PF(x))
    13 
    14 using namespace std;
    15 const int INF=1<<31-1;
    16 const int max9=1e9;
    17 const int max6=1e6;
    18 const int max3=1e3;
    19 
    20 int gcd(int a,int b)
    21 {
    22     return b==0?a:gcd(b,a%b);
    23 }
    24 
    25 int main()
    26 {
    27     int n,m;
    28     while(cin >> n >> m)
    29     {
    30         int Ans=(n+m)/3;
    31         Ans=min(Ans,n);
    32         Ans=min(Ans,m);
    33         cout << Ans << endl;
    34     }
    35     return 0;
    36 }
    View Code
  • 相关阅读:
    手工卸载.Net写的win服务
    程序员素质面试题
    GridView数据导出功能
    使用EventLog类写系统日志
    HTML Response ContentType 大全
    用C#做短信CMPP2.0/3.0协议 支持扩展号支持物理网卡
    CYQ.Data 轻量数据层之路 使用篇MAction 数据查询 视频 E (二十二)
    CYQ.Data 轻量数据层之路 V2.0 震撼惊世 支持多数据库/内置Aop(二十五)
    MapXtreme 2005 GIS开发入门系列 索引
    CYQ.Data 轻量数据层之路 框架如何应对数据库变化
  • 原文地址:https://www.cnblogs.com/I-love-HLD/p/4306582.html
Copyright © 2011-2022 走看看