結果

問題 No.966 引き算をして門松列(その1)
ユーザー brthyyjpbrthyyjp
提出日時 2020-04-16 17:49:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,384 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 78,008 KB
最終ジャッジ日時 2024-04-09 21:19:07
合計ジャッジ時間 1,589 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

t = int(input())
for i in range(t):
    a, b, c = map(int, input().split())
    l = [a, b, c]
    if len(set(l)) == 1:
        if a == 1 or a == 2:
            print(-1)
        else:
            print(3)
    elif len(set(l)) == 2:
        print(0)
    else:
        l.sort(reverse=True)
        if a == l[0] and b == l[1] and c == l[2]:
            ans1 = a-b+1
            if b-1 == c:
                if c == 1:
                    ans1 = -1
                else:
                    ans1 += 1
            ans2 = b-c+1
            if c == 1:
                ans2 = -1
            if ans1 == -1 and ans2 == -1:
                print(-1)
            else:
                print(min(ans1, ans2))
        elif a == l[0] and b == l[2] and c == l[1]:
            print(0)
        elif a == l[1] and b == l[0] and c == l[2]:
            print(0)
        elif a == l[1] and b == l[2] and c == l[0]:
            print(0)
        elif a == l[2] and b == l[0] and c == l[1]:
            print(0)
        else:
            a, c = c, a
            ans1 = a-b+1
            if b-1 == c:
                if c == 1:
                    ans1 = -1
                else:
                    ans1 += 1
            ans2 = b-c+1
            if c == 1:
                ans2 = -1
            if ans1 == -1 and ans2 == -1:
                print(-1)
            else:
                print(min(ans1, ans2))
0