結果
問題 |
No.1748 Parking Lot
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:57:03 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,144 bytes |
コンパイル時間 | 338 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 52,352 KB |
最終ジャッジ日時 | 2025-03-31 17:58:20 |
合計ジャッジ時間 | 1,704 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 WA * 19 |
ソースコード
def find_last_position(N, K): left = K - 1 right = N - K left_steps = 0 right_steps = 0 total_steps = N - 1 # number of cars to park after the first while total_steps > 0: if left > right: take = min(total_steps, left - right) left_steps += take left -= take total_steps -= take elif right > left: take = min(total_steps, right - left) right_steps += take right -= take total_steps -= take else: pairs = total_steps // 2 left_steps += pairs right_steps += pairs left -= pairs right -= pairs total_steps -= 2 * pairs if total_steps > 0: left_steps += 1 left -= 1 total_steps -= 1 if right_steps > left_steps: return N - (right_steps - 1) elif left_steps > right_steps: return left_steps else: return K - left_steps if left > right else K + right_steps # Read input N, K = map(int, input().split()) print(find_last_position(N, K))