#D. Team Composition: Programmers and Mathematicians

    Type: RemoteJudge 1000ms 256MiB

Team Composition: Programmers and Mathematicians

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Team Composition: Programmers and Mathematicians

题面翻译

All-Berland 团队编程赛即将举行。今年,允许由四个人组成的团队参加。

aa 个程序员和 bb 个数学家,在以下情况中,他们最多能组建多少支队伍?

  • 每个团队的必须恰好为 44 人;
  • 不组建由 44 个数学家或 44 个程序员组成的队伍。即每个队伍至少要包含一名数学家和一名程序员。

每人最多只能加入一个队伍,输出最多能组建队伍的数量。

题目描述

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

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

  • each team must consist of exactly 4 4 students,
  • teams of 4 4 mathematicians or 4 4 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.

输入格式

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

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

输出格式

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

样例 #1

样例输入 #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 2 2 programmers and 2 2 mathematicians.

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

20230311-二分法-随堂测验

Not Attended
Status
Done
Rule
Ledo
Problem
7
Start at
2023-3-11 10:30
End at
2023-4-5 10:30
Duration
600 hour(s)
Host
Partic.
34