309007: CF1611B. Team Composition: Programmers and Mathematicians
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Team Composition: Programmers and Mathematicians
题意翻译
All-Berland 团队编程赛即将举行。今年,允许由四个人组成的团队参加。 有 $a$ 个程序员和 $b$ 个数学家,在以下情况中,他们最多能组建多少支队伍? - 每个团队的必须恰好为 $4$ 人; - 不组建由 $4$ 个数学家或 $4$ 个程序员组成的队伍。即每个队伍至少要包含一名数学家和一名程序员。 每人最多只能加入一个队伍,输出最多能组建队伍的数量。题目描述
The All-Berland Team Programming Contest will take place very soon. This year, teams of four are allowed to participate. There are $ a $ programmers and $ b $ mathematicians at Berland State University. How many maximum teams can be made if: - each team must consist of exactly $ 4 $ students, - teams of $ 4 $ mathematicians or $ 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 $ ( $ 1 \le t \le 10^4 $ ) —the number of test cases. This is followed by descriptions of $ t $ sets, one per line. Each set is given by two integers $ a $ and $ b $ ( $ 0 \le a,b \le 10^9 $ ).
输出格式
Print $ t $ lines. Each line must contain the answer to the corresponding set of input data — the required maximum number of teams.
输入输出样例
输入样例 #1
6
5 5
10 1
2 3
0 0
17 2
1000000000 1000000000
输出样例 #1
2
1
1
0
2
500000000