結果

問題 No.967 引き算をして門松列(その2)
ユーザー neterukunneterukun
提出日時 2020-01-13 21:12:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 435 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 78,584 KB
最終ジャッジ日時 2023-08-24 13:53:11
合計ジャッジ時間 2,612 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,492 KB
testcase_01 AC 70 ms
71,400 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 #

t = int(input())

for tt in range(t):
    a = list(map(int, input().split()))
    ans = 10**18
    for i, j, k in [(0, 2, 1), (1, 2, 0) ,(1, 0, 2), (2, 0, 1)]:
        tmp1 = max(a[j] - a[i] + 1, 0)
        aj = a[j] - tmp1
        tmp2 = max(a[k] - aj + 1, 0)
        ak = a[k] - tmp2
        if ak > 0:
            ans = min(ans, tmp1 * a[i + 2] + tmp2 * a[j + 2])
    if ans == 10**18:
        print(-1)
    else:
        print(ans)
0