結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,864 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 81 ms
7,808 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