結果

問題 No.1052 電子機器X
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-04-06 23:01:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 71,664 KB
最終ジャッジ日時 2023-08-18 14:54:54
合計ジャッジ時間 2,971 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,364 KB
testcase_01 AC 71 ms
71,208 KB
testcase_02 AC 71 ms
71,180 KB
testcase_03 WA -
testcase_04 AC 71 ms
71,300 KB
testcase_05 AC 72 ms
71,292 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 71 ms
71,248 KB
testcase_09 WA -
testcase_10 AC 77 ms
71,232 KB
testcase_11 AC 71 ms
70,976 KB
testcase_12 AC 71 ms
71,364 KB
testcase_13 WA -
testcase_14 AC 71 ms
71,368 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 74 ms
71,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())

if n%2:
    if k%2:
        l1 = 2
        r1 = min(1+k,n-1)
        r2 = n
        l2 = max(1,n-k+1)
    else:
        l1 = 1
        r1 = min(n,1+k)
        r2 = n-1
        l2 = max(2,n-k+1)


    ans = (r1-l1)//2+(r2-l2)//2+2
else:

    if k%2:
        l1 = 2
        r1 = min(1+k,n)
        r2 = n
        l2 = max(2,n-k+1)
    else:
        l1 = 1
        r1 = min(n-1,1+k)
        r2 = n-1
        l2 = max(1,n-k+1)

    if r1 <= l2:
        ans = (r2-l1)//2+1
    else:
        ans = (r1-l1)//2+(r2-l2)//2+2
print(ans)
0