結果

問題 No.126 2基のエレベータ
ユーザー te-sh
提出日時 2017-01-30 17:18:14
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 429 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 102,676 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 06:43:39
合計ジャッジ時間 1,557 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;      // math functions

void main()
{
  auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1], s = rd[2];

  auto calc() {
    if (s == 1 || (s - a).abs <= (s - b).abs)
      return (s - a).abs + s;

    auto m1 = (s - b).abs + (s - a).abs + a;
    auto m2 = (s - b).abs + (s - 1) + (a - 1) + 1;
    return min(m1, m2);
  }

  writeln(calc);
}
0