zoukankan      html  css  js  c++  java
  • Codeforces Round #294 (Div. 2)——C——A and B and Team Training

    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大人2小孩,2大人1小孩(不要在意细节!),问你多少种组合最多

    因为最后要么是全部的m用完要么是全部的n用完要么是(m+n)/3(每一组都三个),没有别的情况了只要取这三个里面的最小值就行。

    #include<cstdio>
    #include<algorithm>
    using namespace std;
    int n,m;
    int mine(int a,int b,int c){
    return min(min(a,b),min(b,c));
    }
    int main()
    {
        while(~scanf("%d%d",&n,&m))
            printf("%d
    ",mine(n,m,(n+m)/3));
       return 0;
    }
    View Code
  • 相关阅读:
    SpringRMI解析3-RmiServiceExporter逻辑细节
    SpringRMI解析2-RmiServiceExporter逻辑脉络
    SpringRMI解析1-使用示例
    SpringMVC解析5-DispatcherServlet逻辑细节
    SpringMVC解析4-DispatcherServlet逻辑脉络
    SpringMVC解析3-DispatcherServlet组件初始化
    SpringMVC解析2-ContextLoaderListener
    算法笔记_074:子集和问题(Java)
    算法笔记_073:哈密顿回路问题(Java)
    算法笔记_072:N皇后问题(Java)
  • 原文地址:https://www.cnblogs.com/zero-begin/p/4350064.html
Copyright © 2011-2022 走看看