結果

問題 No.966 引き算をして門松列(その1)
ユーザー titiatitia
提出日時 2020-01-13 20:36:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 896 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 11,072 KB
実行使用メモリ 8,272 KB
最終ジャッジ日時 2023-08-23 13:07:39
合計ジャッジ時間 1,039 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

T=int(input())

def check(A,B,C):
    if min(A,B,C)<=0:
        return 0
    if A==B or B==C or C==A:
        return 0
    if B==max(A,B,C) or B==min(A,B,C):
        return 1
    return 0

    

for test in range(T):
    A,B,C=map(int,input().split())

    if check(A,B,C)==1:
        print(0)
        continue

    if A==B==C:
        if A>=3:
            print(3)
        else:
            print(-1)
        continue

    ANS=1<<60
    if A>=B and check(B-1,B,C)==1:
        ANS=min(ANS,A-(B-1))

    if A>=C and check(C-1,B,C)==1:
        ANS=min(ANS,A-(C-1))

    if B>=A and check(A,A-1,C)==1:
        ANS=min(ANS,B-(A-1))

    if B>=C and check(A,C-1,C)==1:
        ANS=min(ANS,B-(C-1))

    if C>=A and check(A,B,A-1)==1:
        ANS=min(ANS,C-(A-1))

    if C>=B and check(A,B,B-1)==1:
        ANS=min(ANS,C-(B-1))

    if ANS==1<<60:
        print(-1)
    else:
        print(ANS)
    

0