結果

問題 No.968 引き算をして門松列(その3)
ユーザー yomo3yomo3
提出日時 2020-01-22 12:58:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 716 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 8,292 KB
最終ジャッジ日時 2023-09-22 06:11:19
合計ジャッジ時間 2,132 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,760 KB
testcase_01 AC 17 ms
7,920 KB
testcase_02 AC 17 ms
7,832 KB
testcase_03 AC 51 ms
8,220 KB
testcase_04 AC 50 ms
8,252 KB
testcase_05 AC 51 ms
8,292 KB
testcase_06 AC 50 ms
8,288 KB
testcase_07 AC 52 ms
8,140 KB
testcase_08 AC 74 ms
8,248 KB
testcase_09 AC 106 ms
7,752 KB
testcase_10 AC 109 ms
8,168 KB
testcase_11 AC 109 ms
8,148 KB
権限があれば一括ダウンロードができます

ソースコード

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