結果

問題 No.126 2基のエレベータ
ユーザー fiord
提出日時 2015-04-26 16:46:06
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 325 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 62,024 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-10 18:25:33
合計ジャッジ時間 1,425 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;
	int count=0;
	if(a==0){
		a++; count++;
	}
	if(s==1) count+=abs(a-s)+1;
	else if(abs(a-s)<=abs(b-s))	count+=abs(a-s)+s;
	else count+=abs(b-s)+min(abs(a-s)+a,s-1+abs(a-1)+1);
	cout<<count<<endl;
	return 0;
}
0