結果

問題 No.126 2基のエレベータ
ユーザー fiordfiord
提出日時 2015-04-26 16:35:33
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 271 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 60,744 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 02:49:42
合計ジャッジ時間 1,366 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int a,b,s;	cin>>a>>b>>s;
	if(s==1) cout<<abs(a-s)+1;
	else if(abs(a-s)<=abs(b-s))	cout<<abs(a-s)+s;
	else cout<<abs(b-s)+min(abs(a-s)+a,s-1+abs(a-1)+1);
	cout<<endl;
	return 0;
}
0