結果

問題 No.967 引き算をして門松列(その2)
ユーザー yomo3
提出日時 2020-01-22 12:39:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-07 22:20:12
合計ジャッジ時間 1,691 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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