結果

問題 No.126 2基のエレベータ
ユーザー tubo28tubo28
提出日時 2015-04-08 17:54:38
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 355 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 11,392 KB
実行使用メモリ 15,412 KB
最終ジャッジ日時 2023-09-17 18:50:34
合計ジャッジ時間 3,990 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 81 ms
15,236 KB
testcase_03 AC 81 ms
15,300 KB
testcase_04 AC 80 ms
15,056 KB
testcase_05 AC 82 ms
15,200 KB
testcase_06 AC 81 ms
15,056 KB
testcase_07 RE -
testcase_08 AC 80 ms
15,244 KB
testcase_09 AC 82 ms
15,260 KB
testcase_10 AC 82 ms
15,164 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 80 ms
15,116 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 80 ms
15,268 KB
testcase_19 AC 80 ms
15,044 KB
testcase_20 RE -
testcase_21 AC 79 ms
15,180 KB
testcase_22 AC 79 ms
15,096 KB
testcase_23 AC 79 ms
15,144 KB
testcase_24 AC 80 ms
15,244 KB
testcase_25 AC 79 ms
15,256 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# coding: utf-8

a,b,s = gets.chomp.split.map(&:to_i)
ans = 0
if (a-s).abs <= (b-s).abs || s==1
  # AをSに呼ぶ
  ans += (a-s).abs
  # Aを使って0に行く
  ans += s.abs
else
  # BをSに呼ぶ
  ans += (b-s).abs
  # Aに行って0に行くか、1に行ってAを呼んで0に行くか
  t = [(b-a).abs + a, (s-1).abs + a]
  ans += t
end

puts ans
0