結果

問題 No.966 引き算をして門松列(その1)
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-14 17:07:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-04-30 00:53:27
合計ジャッジ時間 1,663 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
52,096 KB
testcase_01 AC 40 ms
51,584 KB
testcase_02 AC 41 ms
51,712 KB
testcase_03 AC 42 ms
51,840 KB
testcase_04 AC 169 ms
77,056 KB
testcase_05 AC 157 ms
76,800 KB
testcase_06 AC 161 ms
77,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
INF = 10**18
for i in range(t):
    a, b, c = map(int, input().split())
    base = 0
    if a == c:
        if a == 1:
            base = INF
        else:
            a -= 1
            base = 1
    if a > c:
        a, c = c, a
    ans1 = base
    if a < b and c < b:
        pass
    else:
        if b >= 3:
            if a >= b-2:
                ans1 += a-(b-2)
            if c >= b-1:
                ans1 += c-(b-1)
        else:
            ans1 = INF
    ans2 = base
    if b < a and b < c:
        pass
    else:
        if a >= 2:
            ans2 += b-(a-1)
        else:
            ans2 = INF
    ans = min(ans1, ans2)
    if ans < INF:
        print(ans)
    else:
        print(-1)
0