結果

問題 No.3173 じゃんけんの勝ちの回数
ユーザー t98slider
提出日時 2025-02-23 23:48:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,084 ms / 2,000 ms
コード長 812 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 78,756 KB
最終ジャッジ日時 2025-02-23 23:48:37
合計ジャッジ時間 35,318 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

T = int(input())
# 順列を生成
Permut = list(itertools.permutations([[0, 0], [0, 2], [1, 0], [1, 1], [2, 1], [2, 2]]))

for testcase in range(T):
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    # 最大値の答え
    maxv = min(A[0], B[1]) + min(A[1], B[2]) + min(A[2], B[0])

    # あいこと負けの最大値
    mx_used = 0
    # 順列全探索でどの順で使用するかを全探索
    for P in Permut:
        tot = 0
        tmp_A = A.copy()
        tmp_B = B.copy()
        for u, v in P:
            d = min(tmp_A[u], tmp_B[v])
            tmp_A[u] -= d
            tmp_B[v] -= d
            tot += d
        mx_used = max(mx_used, tot)

    # 最小値の答え
    minv = sum(A) - mx_used

    # 答えを出力
    print(minv, maxv)
0