問題一覧 > 通常問題

No.3173 Number of Wins in Rock-Paper-Scissors

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 64
作問者 : t98slider / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 11981 / 自分の提出
問題文最終更新日: 2025-06-02 05:54:32
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 469 (順位表) の他の問題:
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
If everyone playing shows the same hand, or if there are 1 or more people showing each of rock, scissors, and paper, the result is a draw.

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.
Find the minimum and maximum possible numbers of wins for Yukiko when they play rock-paper-scissors ${\displaystyle \sum_{i=1}^{3} A_{i}}$ times.

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もしくは右上の雲マークをクリックしてアカウントを作成してください。