ACMT - Acm Teams
Engineer Ahmed Sror one of the best coaches. He picks team members by using two ways.
First one 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.
Second one that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.
All the teams during the training session should belong to one of the two ways described above. Furthermore, they agree that the total number of teams should be as high as possible.
There are E experienced members and N newbies on the training session. Can you calculate what maximum number of teams can be formed?
Input
The first line of the input contains a single integer corresponding to number of test cases t (1 ≤ t ≤ 10) ,The second line contains two integers E and N (0 ≤ E, N ≤ 5·105) — the number of experienced participants and newbies that are present at the training session.
Output
For each test case print a single integer representing the maximum number of teams that can be formed.
Example
Input: 2 2 6 4 5 Output: 2 3
Note 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).
hide comments
pragyavyas:
2017-01-27 18:35:12
NO RECURSION ......just a simple logic .....AC in 1 go...:-) |
|
cs_abhi2000:
2017-01-15 15:34:49
Recursion works...
|
|
zyloc:
2016-04-05 21:32:47
Ac in one go :D |
|
minhthai:
2016-04-05 18:00:57
don't think too much :D:D
|
|
avinashgurjar:
2016-03-13 19:41:46
can,t believe it .damn easy
|
|
ayush sinha:
2016-02-20 10:54:28
lolipop ques
|
|
farhan764:
2016-01-20 22:54:29
damn easy............got me 4 WA's .....silly mistaks......python 4 lines |
|
prakash_reddy:
2016-01-06 19:05:00
easy one... |
|
shravinson:
2015-09-10 14:18:19
recursion=> TLE
|
|
joydeepdas123:
2015-09-03 10:10:55
in 1 go... |
Added by: | atef |
Date: | 2015-04-23 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |