結果

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

ソースコード

diff #

INF = 10**20

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

def f132(a,b,c,x,y,z):
    res = 0
    if b >= c:
        d = b - c + 1
        a -= d
        b -= d
        res += d * x
    if c >= a:
        d = c - a + 1
        b -= d
        c -= 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,y,x,z), f132(a,b,c,x,y,z), f132(c,b,a,y,x,z))
    if ans == INF: ans = -1
    print(ans)
0