結果

問題 No.966 引き算をして門松列(その1)
ユーザー 👑 KazunKazun
提出日時 2020-11-12 04:44:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 566 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 77,892 KB
最終ジャッジ日時 2023-09-30 01:01:43
合計ジャッジ時間 1,570 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def cost(A,B):
    if B<=0:
        return inf
    else:
        return max(A-B,0)

T=int(input())
X=[0]*T
inf=float("inf")

for i in range(T):
    A,B,C=map(int,input().split())
    K=0
    if A==C:
        A-=1
        K=1
    A,C=min(A,C),max(A,C)

    if A<=0:
        X[i]=-1
        continue

    if A==B:
        X[i]=1+K
        continue

    if B==C:
        if A+1==C:
            X[i]=2+K
        else:
            X[i]=1+K
        continue

    if B<A or C<B:
        continue

    X[i]=K+cost(B,A-1)
    if X[i]==inf:
        X[i]=-1

print(*X,sep="\n")
0