結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-01-28 01:01:55 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 450 bytes |
| コンパイル時間 | 616 ms |
| コンパイル使用メモリ | 60,664 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-10 18:24:07 |
| 合計ジャッジ時間 | 1,600 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
#include <list>
using namespace std;
int main(int argc, char *argv[])
{
int A, B, S;
string s;
getline(cin, s);
stringstream ss(s);
ss >> A >> B >> S;
int ans = 0;
int a = abs(A - S), b = abs(B - S);
if (a <= b || S <= 1) {
ans = a + S;
} else {
int c = b + a + abs(A - 1) + 1;
int d = b + (S - 1) + abs(A - 1) + 1;
ans = min(c, d);
}
cout << ans << endl;
return 0;
}
hotpepsi