結果
問題 | No.126 2基のエレベータ |
ユーザー |
|
提出日時 | 2016-03-05 13:27:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 429 bytes |
コンパイル時間 | 548 ms |
コンパイル使用メモリ | 58,624 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-10 18:28:51 |
合計ジャッジ時間 | 1,560 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <iostream> #include <math.h> using namespace std; int main() { int a, b, s; cin >> a >> b >> s; int res; int a_to_s = abs(a - s); int b_to_s = abs(b - s); if (b_to_s < a_to_s && s != 1) { res = b_to_s + a; if (s - 1 < a_to_s) { if (a == 0) { res += s + 1; } else { res += s - 1; } } else { res += a_to_s; } } else { res = a_to_s + s; } cout << res << endl; return 0; }