結果

問題 No.966 引き算をして門松列(その1)
ユーザー roarisroaris
提出日時 2020-01-15 21:01:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,064 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 79,388 KB
最終ジャッジ日時 2023-09-02 13:18:24
合計ジャッジ時間 2,010 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,248 KB
testcase_01 AC 77 ms
71,288 KB
testcase_02 AC 75 ms
71,112 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 181 ms
78,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for _ in range(T):
    A, B, C = map(int, input().split())
    
    if len(set([A, B, C]))==3 and (B==max(A, B, C) or B==min(A, B, C)):
        print(0)
        continue
    
    if (A>B and B>C) or (A>B and B==C):
        A, C = C, A
    
    if A<B and B<C:
        if A==1:
            if B==2:
                print(-1)
            elif B==A+1:
                print(C-(B-2))
            else:
                print(C-(B-1))
        else:
            if B==A+1:
                print(min(B-(A-1), C-(B-2)))
            else:
                print(min(B-(A-1), C-(B-1)))
    elif A==B and B<C:
        if A==1:
            print(-1)
        else:
            print(1)
    elif A==B==C:
        if A<=2:
            print(-1)
        else:
            print(3)
    elif B==max(A, B, C):
        if A==1:
            print(-1)
        else:
            print(1)
    elif B==min(A, B, C):
        if A==2:
            print(-1)
        else:
            if A==B+1:
                print(A-(B-1)+C-(B-2))
            else:
                print(1)
0