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