結果

問題 No.967 引き算をして門松列(その2)
ユーザー tamatotamato
提出日時 2020-01-13 21:30:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,264 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 86,608 KB
実行使用メモリ 78,272 KB
最終ジャッジ日時 2023-08-24 15:15:40
合計ジャッジ時間 2,589 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,952 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.readline

    T = int(input())
    for _ in range(T):
        A, B, C, x, y, z = map(int, input().split())
        
        if B == min(A, B, C) or max(A, B, C):
            if A != B and B != C and C != A:
                print(0)
                continue
        
        # b max
        if B <= 2:
            ans1 = 10**30
        else:
            ans1 = 0
            a = A
            b = B
            c = C
            if a >= b:
                ans1 += x * (a - (b-1))
                a = b-1
            if c >= b:
                ans1 += z * (c - (b-1))
                c = b-1
            if a == c:
                ans1 += min(x, z)

        # b min
        if A == 1 or C == 1 or A == C == 2:
            ans2 = 10**30
        else:
            ans2 = 0
            a = A
            b = B
            c = C
            if a == c:
                if x < z:
                    ans2 += x
                    a -= 1
                else:
                    ans2 += z
                    c -= 1
            ans2 += y * max(b - (min(a, c) - 1), 0)
        ans = min(ans1, ans2)
        if ans == 10**30:
            print(-1)
        else:
            print(ans)


if __name__ == '__main__':
    main()
0