結果

問題 No.967 引き算をして門松列(その2)
ユーザー r_ishidar_ishida
提出日時 2020-01-31 07:28:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,988 KB
実行使用メモリ 10,176 KB
最終ジャッジ日時 2023-10-17 08:12:19
合計ジャッジ時間 2,414 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,160 KB
testcase_01 AC 27 ms
10,160 KB
testcase_02 AC 29 ms
10,160 KB
testcase_03 AC 66 ms
10,176 KB
testcase_04 AC 63 ms
10,176 KB
testcase_05 AC 65 ms
10,176 KB
testcase_06 AC 64 ms
10,176 KB
testcase_07 AC 65 ms
10,176 KB
testcase_08 AC 90 ms
10,176 KB
testcase_09 AC 124 ms
10,176 KB
testcase_10 AC 128 ms
10,176 KB
testcase_11 AC 128 ms
10,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def cost102(a, b, c, x, y, z):
    ret = 0
    if c <= a:
        ret += (a-c+1)*x
        a = c-1
    if a <= b:
        ret += (b - a + 1) * y
        b = a-1
    if a<1 or b<1 or c<1:
        ret = 10**20
    return ret


def cost120(a, b, c, x, y, z):
    ret = 0
    if b <= a:
        ret += (a-b+1)*x
        a = b-1
    if a <= c:
        ret += (c - a + 1) * z
        c = a-1
    if a<1 or b<1 or c<1:
        ret = 10**20
    return ret


t = int(input())
for _ in range(t):
    a,b,c,x,y,z = map(int,input().split())
    cost = []
    cost.append(cost120(a, b, c, x, y, z))
    cost.append(cost120(c, b, a, z, y, x))
    cost.append(cost102(a, b, c, x, y, z))
    cost.append(cost102(c, b, a, z, y, x))
    if min(cost) == 10**20:
        print(-1)
    else:
        print(min(cost))
0