結果

問題 No.966 引き算をして門松列(その1)
ユーザー neterukunneterukun
提出日時 2020-01-13 21:05:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 77,596 KB
最終ジャッジ日時 2023-08-24 13:35:30
合計ジャッジ時間 2,034 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
70,972 KB
testcase_01 AC 70 ms
71,348 KB
testcase_02 AC 69 ms
71,388 KB
testcase_03 AC 70 ms
71,136 KB
testcase_04 AC 136 ms
77,596 KB
testcase_05 AC 129 ms
77,560 KB
testcase_06 AC 131 ms
77,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())

for _ 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 + tmp2)
    if ans == 10**18:
        print(-1)
    else:
        print(ans)
0