結果

問題 No.968 引き算をして門松列(その3)
ユーザー kimiyukikimiyuki
提出日時 2020-01-13 21:11:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 882 bytes
コンパイル時間 2,774 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 81,164 KB
最終ジャッジ日時 2023-08-24 13:49:58
合計ジャッジ時間 5,456 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,096 KB
testcase_01 AC 73 ms
71,536 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import math

def iterate(a, b, c):
    for a in range(a, a + 4):
        for b in range(b, b + 4):
            for c in range(c, c + 4):
                yield a, b, c
                yield max(b + 1, a), b, max(b + 2, c)
                yield max(b + 2, a), b, max(b + 1, c)
                yield a, max(a + 1, b), c
                yield a, max(c + 1, b), c

def solve(a, b, c, x, y, z):
    ans = math.inf
    for na, nb, nc in iterate(a, b, c):
        if na != nc and ((na < nb and nb > nc) or (na > nb and nb < nc)):
            da = na - a
            db = nb - b
            dc = nc - c
            if a - db - dc >= 1 and b - dc - da >= 1 and c - da - db >= 1:
                ans = min(ans, x * da + y * db + z * dc)
    if math.isinf(ans):
        return -1
    return ans

for _ in range(int(input())):
    print(solve(*map(int, input().split())))
0