結果

問題 No.966 引き算をして門松列(その1)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-04-20 23:30:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 79,480 KB
最終ジャッジ日時 2023-09-02 19:43:48
合計ジャッジ時間 2,597 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,280 KB
testcase_01 AC 72 ms
71,144 KB
testcase_02 AC 73 ms
71,200 KB
testcase_03 AC 72 ms
71,192 KB
testcase_04 AC 186 ms
79,480 KB
testcase_05 AC 180 ms
78,896 KB
testcase_06 AC 190 ms
78,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

inf = 10**20
def calc1(a,b,c):
    count = 0
    if b <= c:
        count += c-b+1
        c = b-1
    if a >= c:
        count += a-c+1
        a = c-1
    if a > 0:
        return count
    return inf


def calc2(a,b,c):
    count = 0
    if a == c:
        a -= 1
        count += 1
    if b >= a:
        count += b-a+1
        b = a-1
    if b > 0:
        return count
    return inf

t = int(input())
for _ in range(t):
    a,b,c = map(int,input().split())
    if c < a:
        a,c = c,a

    ans = min(calc1(a,b,c),calc2(a,b,c))
    if ans == inf:
        ans = -1
    print(ans)
0