結果

問題 No.966 引き算をして門松列(その1)
ユーザー kimiyukikimiyuki
提出日時 2020-01-13 20:53:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 393 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2023-08-23 13:37:51
合計ジャッジ時間 1,004 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def solve(a,b,c):
    if a==c==1:
        return -1
    if a==c:
        return 1+solve(a,b,c-1)
    if a>c:
        return solve(c,b,a)
    assert 1<=a<c
    if c<b or b<a:
        return 0
    if a==1:
        return -1
    if b==1 or b==2:
        return b-(a-1)
    return min(b-(a-1),c-(b-1)+min(a,b-2)-a)
for _ in range(int(input())):
 a,b,c=map(int,input().split())
 print(solve(a,b,c))
0