結果

問題 No.126 2基のエレベータ
ユーザー kongarishisyamo
提出日時 2016-05-23 16:01:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 366 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 60,916 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-10 18:30:05
合計ジャッジ時間 1,360 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;


int main(){
	
	int A, B, S;

	cin >> A >> B >> S;

	if (abs(A - S) <= abs(B - S) || S == 1) cout << abs(A - S) + S << endl;
	else if (A != 0) cout << abs(B - S) + min(abs(A - S) + +A, abs(S - 1) + abs(A - 1) + 1) << endl;
	else cout << abs(B - S) + abs(S - 1) + abs(A - 1) + 1 << endl;
}
0