結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-30 17:19:59 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 786 ms |
| コンパイル使用メモリ | 102,624 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-12 06:43:55 |
| 合計ジャッジ時間 | 1,802 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
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 = a > 0 ? (s - b).abs + (s - a).abs + a : int.max;
auto m2 = (s - b).abs + (s - 1) + (a - 1).abs + 1;
return min(m1, m2);
}
writeln(calc);
}