CF519C.A and B and Team Training

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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?

A 和 B 正在为编程竞赛做准备。

为竞赛做准备的一个重要环节,是让有经验的选手向刚刚接触竞赛的新手分享编程知识。因此,在下一次团队训练中,A 决定组队方式为:让新手与有经验的选手共同解题。

A 认为,由一名有经验的选手和两名新手组成的三人队伍是最优的。这样,每名有经验的选手便能将经验分享给大量新手。

然而,B 认为,由两名有经验的选手和一名新手组成的三人队伍才是最优的。这样,每名新手便能获得更多的知识和经验。

最终,A 和 B 达成一致:训练期间的所有队伍必须属于上述两种类型之一;此外,他们希望队伍的总数尽可能多。

训练期间共有 nn 名有经验的选手和 mm 名新手。请问最多可以组成多少支队伍?

输入格式

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.

第一行包含两个整数 nn 和 mm(0 ≤ n, m ≤ 5⋅1050 \leq n, m \leq 5\cdot10^5)—— 分别表示训练营中经验丰富的参与者和新手的数量。

输出格式

Print the maximum number of teams that can be formed.

输出最多可以组成的队伍数量。

输入输出样例

  • 输入#1

    2 6

    输出#1

    2
  • 输入#2

    4 5

    输出#2

    3

说明/提示

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

我们将经验丰富的玩家表示为 XP,新手表示为 NB。

在第一个测试用例中,队伍如下所示:(XP, NB, NB), (XP, NB, NB)。

在第二个测试用例中,队伍如下所示:(XP, NB, NB), (XP, NB, NB), (XP, XP, NB)。

输入解题思路,AI测评打分。不知道怎么写?

首页