Codeforces Round 1067 (Div. 2)
A
Suspension
Codeforces
800
原题
←B →
翻译中…

A game is being played which initially consists of $n$ players. On fouls, the referee is allowed to award yellow and red cards. The total number of yellow cards $y$ and red cards $r$ awarded to players is known for the game.

翻译中…

There are $2$ ways a player can be suspended:

翻译中…
  • Receiving a red card.
  • Receiving $2$ yellow cards.
翻译中…

Once a player is suspended, they are removed from the game and can't receive any more cards. Determine the maximum number of players suspended from the game possible.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first line of each test case contains an integer $n$ ($1 \le n \le 100$).

翻译中…

The second line of each test case contains two integers $y$ and $r$ ($0 \le r \le n$, $0 \le y + r \le 2n$).

翻译中…

Output

翻译中…

For each test case, print one line containing a single integer — denoting the maximum number of players suspended from the game possible.

翻译中…

Note

翻译中…

For the first test case:

翻译中…
  • One of the possible ways to achieve maximum: Player $2$ receives a red card, Player $3$ receives a yellow card followed by a red card.
  • This way Player $2$ and $3$ are suspended.
翻译中…

For the second test case:

翻译中…
  • No cards are awarded at all, so no one is suspended.
翻译中…

For the third test case:

翻译中…
  • One of the possible ways to achieve maximum: Player $1$ receives $2$ yellow cards, Player $2$ receives $2$ yellow cards, and Player $4$ receives $2$ yellow cards.
  • This way Player $1$, $2$, and $4$ are suspended.
翻译中…

样例

Input #1
5
3
1 2
2
0 0
4
6 0
3
3 3
10
11 5
Output #1
2
0
3
3
10
InputCopy OutputCopy
题目信息
题号
2158A
时间限制
1 s
内存限制
256 MB
标签
构造
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。