結果

問題 No.966 引き算をして門松列(その1)
ユーザー tamatotamato
提出日時 2020-01-13 20:40:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,430 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 78,800 KB
最終ジャッジ日時 2023-08-23 13:10:55
合計ジャッジ時間 1,717 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,564 KB
testcase_01 AC 72 ms
71,568 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 148 ms
77,964 KB
testcase_06 AC 154 ms
78,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.readline

    T = int(input())
    for _ in range(T):
        a, b, c = map(int, input().split())
        if a == b == c:
            if a > 2:
                print(3)
            else:
                print(-1)
        elif a == c:
            if b > a:
                if a > 1:
                    print(1)
                else:
                    print(-1)
            elif b == a-1:
                if b > 1:
                    print(2)
                else:
                    print(-1)
            else:
                print(1)
        elif a == b or b == c:
            if max(a, b, c) > b:
                if b > 1:
                    print(1)
                else:
                    print(-1)
            elif min(a, b, c) == b-1:
                if b > 2:
                    print(2)
                else:
                    print(-1)
            else:
                print(1)
        else:
            if b == max(a, b, c) or b == min(a, b, c):
                print(0)
            else:
                if min(a, b, c) == 1 and b == 2:
                    print(-1)
                    continue
                A = min(a, b, c)
                B = b
                C = max(a, b, c)
                ans1 = B - A + 1
                ans2 = C - B + 1 if B - 1 != A else C - B + 2
                print(min(ans1, ans2))


if __name__ == '__main__':
    main()
0