結果
問題 |
No.859 路線A、路線B、路線C
|
ユーザー |
![]() |
提出日時 | 2025-06-12 17:10:06 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 615 bytes |
コンパイル時間 | 213 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 54,144 KB |
最終ジャッジ日時 | 2025-06-12 17:10:09 |
合計ジャッジ時間 | 1,476 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 5 |
ソースコード
x, y, z = map(int, input().split()) S0, t0 = input().split() t0 = int(t0) S1, t1 = input().split() t1 = int(t1) if S0 == S1: print(abs(t0 - t1)) else: routes = {'A': (1, x), 'B': (1, y), 'C': (1, z)} S = S0 T = S1 S_start, S_end = routes[S] T_start, T_end = routes[T] # Compute the four possible costs cost1 = abs(t0 - S_start) + 1 + abs(t1 - T_start) cost2 = abs(t0 - S_end) + 1 + abs(t1 - T_end) cost3 = abs(t0 - S_start) + 2 + abs(t1 - T_end) cost4 = abs(t0 - S_end) + 2 + abs(t1 - T_start) min_cost = min(cost1, cost2, cost3, cost4) print(min_cost)