Team Composition

Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 512M

Problem types

You should know by now that a standard ICPC-style team consists of three students. The best teams, however, have a more precise composition. Students generally specialise into being coders, mathematicians or physicists. A student can only specialise into one category.

A team is considered perfect if it includes at least one coder, at least one mathematician and consists of three members (physicists seem to have a good grasp of both skillsets).

As a coach at a disturbingly large university you know that \(c\) students are coders, \(m\) are mathematicians and \(p\) are physicists.

How many perfect teams can you make?

Some students will be left without a team and obviously no student can be part of two teams.

You need to compute the number of teams for \(Q\) distributions of students.

Input Specification

The first line contains a single integer \(Q (1 \leq Q \leq 10000)\).

The next \(Q\) lines contian three integers \(c, m, p (0 \leq c,m,p \leq 10^8)\)

Output Specification

\(Q\) lines containing a single integer, the number of perfect teams possible.

Sample Input 1

1 1 1
0 0 0
0 1 1
3 6 0
100 1 10
4 4 1

Sample Output 1



There are no comments at the moment.