結果
| 問題 |
No.48 ロボットの操縦
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 22:22:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,040 bytes |
| コンパイル時間 | 377 ms |
| コンパイル使用メモリ | 82,148 KB |
| 実行使用メモリ | 53,784 KB |
| 最終ジャッジ日時 | 2025-04-15 22:25:03 |
| 合計ジャッジ時間 | 2,284 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 6 |
ソースコード
X = int(input())
Y = int(input())
L = int(input())
if X == 0 and Y == 0:
print(0)
exit()
min_cost = float('inf')
# Case when X is 0
if X == 0:
if Y >= 0:
cost = (Y + L - 1) // L
else:
cost = 2 + (abs(Y) + L - 1) // L
min_cost = min(min_cost, cost)
# Case when Y is 0
if Y == 0:
cost = 1 + (abs(X) + L - 1) // L
min_cost = min(min_cost, cost)
# Case when both X and Y are non-zero
if X != 0 and Y != 0:
# Candidate 1: process Y first then X
Y_abs = abs(Y)
Y_steps = (Y_abs + L - 1) // L
Y_rotate_cost = 0 if Y >= 0 else 2
X_abs = abs(X)
X_steps = (X_abs + L - 1) // L
cost1 = Y_steps + X_steps + Y_rotate_cost + 1
# Candidate 2: process X first then Y
X_abs = abs(X)
X_steps = (X_abs + L - 1) // L
X_rotate_cost = 1
Y_abs = abs(Y)
Y_steps = (Y_abs + L - 1) // L
direction_change_cost = 1 if Y >= 0 else 2
cost2 = X_steps + Y_steps + X_rotate_cost + direction_change_cost
min_cost = min(min_cost, cost1, cost2)
print(min_cost)
lam6er