結果
問題 |
No.126 2基のエレベータ
|
ユーザー |
![]() |
提出日時 | 2016-02-16 20:08:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 462 bytes |
コンパイル時間 | 616 ms |
コンパイル使用メモリ | 56,800 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 18:28:49 |
合計ジャッジ時間 | 1,584 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <iostream> #include <vector> using namespace std; #define REP(i,s,e) for (int i = s; i < e; i++) #define rep(i,n) REP(i,0,n) int main() { int a, b, s, ans; cin >> a >> b >> s; int da = abs(s - a); int db = abs(s - b); if (da <= db) ans = da + s; else if (a == 0) ans = db + (s-1) + 2; else if (s == 1) ans = a; else ans = db + min(da,s-1) + a; cout << ans << endl; return 0; }