結果
| 問題 | 
                            No.48 ロボットの操縦
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lam6er
                         | 
                    
| 提出日時 | 2025-04-15 22:32:23 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 47 ms / 5,000 ms | 
| コード長 | 776 bytes | 
| コンパイル時間 | 185 ms | 
| コンパイル使用メモリ | 81,692 KB | 
| 実行使用メモリ | 53,784 KB | 
| 最終ジャッジ日時 | 2025-04-15 22:34:36 | 
| 合計ジャッジ時間 | 2,102 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 | 
ソースコード
X = int(input())
Y = int(input())
L = int(input())
dx = abs(X)
dy = abs(Y)
if X == 0 and Y == 0:
    print(0)
    exit()
# Case 1: Y first then X
case1 = 0
y_rot = 0 if Y >= 0 else 2
y_move = (dy + L - 1) // L if dy != 0 else 0
if dx == 0:
    case1 = y_rot + y_move
else:
    x_rot = 1
    x_move = (dx + L - 1) // L
    case1 = y_rot + y_move + x_rot + x_move
# Case 2: X first then Y
case2 = 0
if dx == 0:
    x_rot = 0
    x_move = 0
else:
    x_rot = 1
    x_move = (dx + L - 1) // L
if dy == 0:
    case2 = x_rot + x_move
else:
    if dx == 0:
        y_rot_case2 = 0 if Y >= 0 else 2
    else:
        y_rot_case2 = 1
    y_move_case2 = (dy + L - 1) // L
    case2 = x_rot + x_move + y_rot_case2 + y_move_case2
min_commands = min(case1, case2)
print(min_commands)
            
            
            
        
            
lam6er