結果

問題 No.966 引き算をして門松列(その1)
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-14 16:54:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,184 KB
最終ジャッジ日時 2024-04-30 00:38:48
合計ジャッジ時間 1,951 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,968 KB
testcase_01 AC 40 ms
51,584 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
権限があれば一括ダウンロードができます

ソースコード

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 and c >= b-1:
                ans1 += a-(b-2)+c-(b-1)
            else:
                ans1 = INF
        else:
            ans1 = INF
    ans2 = base
    if b < a and b < c:
        ans2 = 0
    else:
        if a >= 2:
            ans2 += b-(a-1)
        else:
            ans2 = INF
    ans = min(ans1, ans2)
    if ans < INF:
        print(ans)
    else:
        print(-1)
0