結果

問題 No.1748 Parking Lot
ユーザー gew1fw
提出日時 2025-06-12 18:35:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 82,744 KB
実行使用メモリ 60,480 KB
最終ジャッジ日時 2025-06-12 18:35:31
合計ジャッジ時間 6,438 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 12 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())

left_end = K - 1
right_end = N
cnt = N - 1
ans = K  # This will be overwritten except when N=1

while cnt > 0:
    L = left_end
    R = right_end - K  # right_end - (K + 1) + 1 = right_end - K
    
    if L > R:
        max_steps = L - R
        t = min(max_steps, cnt)
        ans = left_end - t + 1
        left_end -= t
        cnt -= t
    elif R > L:
        max_steps = R - L
        t = min(max_steps, cnt)
        ans = right_end - t + 1
        right_end -= t
        cnt -= t
    else:
        # L == R, choose left
        ans = left_end
        left_end -= 1
        cnt -= 1

print(ans)
0