結果
問題 |
No.126 2基のエレベータ
|
ユーザー |
|
提出日時 | 2015-05-25 00:06:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 623 ms |
コンパイル使用メモリ | 59,320 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 18:26:57 |
合計ジャッジ時間 | 1,670 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <string> using namespace std; int main() { int a, b, s; cin >> a >> b >> s; int ans; if (s == 1 || abs(a - s) <= abs(b - s)) { ans = abs(a - s) + s; } else { ans = abs(b - s); if (a == 0) { ans += s - 1 + 2; } else { ans += min(abs(s - a) + a, s - 1 + a - 1 + 1); } } cout << ans << endl; return 0; }