結果

問題 No.967 引き算をして門松列(その2)
ユーザー yomo3yomo3
提出日時 2020-01-22 12:39:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 8,272 KB
最終ジャッジ日時 2023-09-22 05:39:28
合計ジャッジ時間 1,628 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,828 KB
testcase_01 AC 17 ms
7,732 KB
testcase_02 AC 18 ms
7,792 KB
testcase_03 AC 52 ms
8,272 KB
testcase_04 AC 50 ms
7,844 KB
testcase_05 AC 51 ms
8,272 KB
testcase_06 AC 51 ms
8,168 KB
testcase_07 AC 52 ms
8,160 KB
testcase_08 AC 72 ms
7,988 KB
testcase_09 AC 103 ms
8,220 KB
testcase_10 AC 106 ms
8,172 KB
testcase_11 AC 106 ms
8,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10**20

def f213(a,b,c,x,y,z):
    res = 0
    if a >= b:
        d = a - b + 1
        a -= d
        res += d * x
    if c >= a:
        d = c - a + 1
        c -= d
        res += d * z
    return res if c > 0 else INF

def f132(a,b,c,x,y,z):
    res = 0
    if c >= a:
        d = c - a + 1
        c -= d
        res += d * z
    if b >= c:
        d = b - c + 1
        b -= d
        res += d * y
    return res if b > 0 else INF

for _ in range(int(input())):
    a, b, c, x, y, z = map(int, input().split())
    ans = min(f213(a,b,c,x,y,z),f213(c,b,a,z,y,x),f132(a,b,c,x,y,z),f132(c,b,a,z,y,x))
    if ans == INF: ans = -1
    print(ans)
0