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 团队编程赛即将举行。今年,允许由四个人组成的团队参加。
有 个程序员和 个数学家,在以下情况中,他们最多能组建多少支队伍?
- 每个团队的必须恰好为 人;
- 不组建由 个数学家或 个程序员组成的队伍。即每个队伍至少要包含一名数学家和一名程序员。
每人最多只能加入一个队伍,输出最多能组建队伍的数量。
题目描述
The All-Berland Team Programming Contest will take place very soon. This year, teams of four are allowed to participate.
There are programmers and mathematicians at Berland State University. How many maximum teams can be made if:
- each team must consist of exactly students,
- teams of mathematicians or 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 ( ) —the number of test cases.
This is followed by descriptions of sets, one per line. Each set is given by two integers and ( ).
输出格式
Print 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 programmers and mathematicians.
In the second test case of the example, only one team can be composed: programmers and mathematician in the team.
20230311-二分法-随堂测验
- 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