CF1611B.Team Composition: Programmers and Mathematicians

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The All-Berland Team Programming Contest will take place very soon. This year, teams of four are allowed to participate.

There are aa programmers and bb mathematicians at Berland State University. How many maximum teams can be made if:

  • each team must consist of exactly 44 students,
  • teams of 44 mathematicians or 44 programmers are unlikely to perform well, so the decision was made not to compose such teams.

Thus, each team must have at least one programmer and at least one mathematician.

Print the required maximum number of teams. Each person can be a member of no more than one team.

全贝尔兰团队编程竞赛即将举行。今年,允许由四人组成的团队参赛。

贝尔兰国立大学共有 aa 名程序员和 bb 名数学家。在满足以下条件的前提下,最多能组成多少支队伍?

  • 每支队伍必须恰好由 44 名学生组成;
  • 由 44 名数学家或 44 名程序员组成的队伍表现通常不佳,因此决定不组建此类队伍。

因此,每支队伍中必须至少包含 11 名程序员和 11 名数学家。

请输出所能组成的最大队伍数量。每个人至多只能属于一支队伍。

输入格式

The first line contains an integer tt (1≤t≤1041 \le t \le 10^4) —the number of test cases.

This is followed by descriptions of tt sets, one per line. Each set is given by two integers aa and bb (0≤a,b≤1090 \le a,b \le 10^9).

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)——测试用例的数量。

接下来是 tt 组数据的描述,每组数据占一行。每组数据由两个整数 aa 和 bb(0≤a,b≤1090 \le a,b \le 10^9)给出。

输出格式

Print tt lines. Each line must contain the answer to the corresponding set of input data — the required maximum number of teams.

输出 tt 行。每行必须包含对应输入数据组的答案——即所需的最大队伍数量。

输入输出样例

  • 输入#1

    6
    5 5
    10 1
    2 3
    0 0
    17 2
    1000000000 1000000000

    输出#1

    2
    1
    1
    0
    2
    500000000

说明/提示

In the first test case of the example, two teams can be composed. One way to compose two teams is to compose two teams of 22 programmers and 22 mathematicians.

In the second test case of the example, only one team can be composed: 33 programmers and 11 mathematician in the team.

在示例的第一个测试用例中,可以组成两支队伍。一种组成两支队伍的方式是:每支队伍由 22 名程序员和 22 名数学家组成。

在示例的第二个测试用例中,只能组成一支队伍:该队伍由 33 名程序员和 11 名数学家组成。

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

首页