結果

問題 No.859 路線A、路線B、路線C
ユーザー letrangerjpletrangerjp
提出日時 2019-08-09 23:29:00
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 933 ms
コンパイル使用メモリ 11,364 KB
実行使用メモリ 15,348 KB
最終ジャッジ日時 2023-09-26 22:07:32
合計ジャッジ時間 3,651 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,252 KB
testcase_01 AC 81 ms
15,096 KB
testcase_02 AC 82 ms
15,176 KB
testcase_03 AC 81 ms
15,348 KB
testcase_04 AC 79 ms
15,140 KB
testcase_05 AC 80 ms
15,044 KB
testcase_06 AC 81 ms
15,328 KB
testcase_07 AC 81 ms
15,168 KB
testcase_08 AC 80 ms
15,256 KB
testcase_09 AC 81 ms
15,052 KB
testcase_10 WA -
testcase_11 AC 81 ms
15,156 KB
testcase_12 AC 81 ms
15,044 KB
testcase_13 AC 82 ms
15,136 KB
testcase_14 AC 83 ms
15,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

X, Y, Z = gets.split.map &:to_i
Start, Goal = $<.map{|s|
  a, b = s.split
  [a, b.to_i]
}.sort

# from x to x
def same(from, to, x, y, z)
  a = to - from
  b = from + y + (x - to)
  c = from + z + (x - to)
  [a, b, c].min
end

# from x to y
def diff(from, to, x, y, z)
  a = from + to - 1
  b = (x - from) + (y - to) + 1
  c = from + z + (y - to)
  d = (x - from) + z + y
  [a, b, c, d].min
end

From, To = Start[1], Goal[1]
case [Start[0], Goal[0]]
when [?A, ?A]
  p same(From, To, X, Y, Z)
when [?A, ?B]
  p diff(From, To, X, Y, Z)
when [?A, ?C]
  p diff(From, To, X, Z, Y)
when [?B, ?B]
  p same(From, To, Y, X, Z)
when [?B, ?C]
  p diff(From, To, Y, Z, X)
when [?C, ?C]
  p same(From, To, Z, X, Y)
end
0