No.3173 Number of Wins in Rock-Paper-Scissors
Rules of rock-paper-scissors (click to expand)
Rock-paper-scissors is a game in which the 3 kinds of hands, rock, scissors, and paper, form a so-called three-way standoff, and the winner and loser are decided by which hand beats which.
Rock, scissors, and paper have the following relationships.
- Rock beats scissors
- Scissors beats paper
- Paper beats rock
Problem Statement
Yukiko and Koyuki play rock-paper-scissors. Their game is subject to the following restrictions and vows.
- Yukiko can play rock $A_{1}$ times, scissors $A_{2}$ times, and paper $A_{3}$ times.
- Koyuki can play rock $B_{1}$ times, scissors $B_{2}$ times, and paper $B_{3}$ times.
- The total number of rock, scissors, and paper plays is equal for Yukiko and Koyuki.
That is, ${\displaystyle \sum_{i=1}^{3} A_{i} = \sum_{i=1}^{3} B_{i}}$ is satisfied.
A draw is also considered to be $1$ completed game of rock-paper-scissors.
Constraints
- $1 \leq T \leq 10^{4}$
- $0 \leq A_{i} \leq 10^{8}$
- $0 \leq B_{i} \leq 10^{8}$
- ${\displaystyle \sum_{i=1}^{3} A_{i} = \sum_{i=1}^{3} B_{i}}$ is satisfied.
- All inputs are integers.
Input
The input is given from standard input in the following format. Here, $\mathrm{case}_i ~ (i = 1, 2, \cdots, T)$ is the $i$-th test case.
$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
Each test case is given in the following format.
$A_{1}$ $A_{2}$ $A_{3}$
$B_{1}$ $B_{2}$ $B_{3}$
Output
Output $T$ lines. On the $i$-th line, output the answer for the $i$-th test case.
For each test case, let $\min$ be the minimum possible number of wins for Yukiko and $\max$ be the maximum possible number, and output them in the following format.
$\min$ $\max$
Sample
Sample 1
Input
6 1 0 0 0 1 0 0 5 1 0 1 5 5 2263 2253 2251 6 2264 3 2 0 1 3 1 314 200 14 14 314 200 100000000 100000000 100000000 100000000 100000000 100000000
Output
1 1 4 5 6 4519 1 4 100 528 0 300000000
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
37zigen