結果

問題 No.126 2基のエレベータ
ユーザー tsukio
提出日時 2016-03-05 13:19:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 373 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 58,080 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 14:17:59
合計ジャッジ時間 1,413 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int a, b, s;
	cin >> a >> b >> s;

	int res;
	int a_to_s = abs(a - s);
	int b_to_s = abs(b - s);

	if (b_to_s < a_to_s && s != 1) {
		res = b_to_s + a;
		if (s - 1 < a_to_s) {
			res += s - 1;
		}
		else {
			res += a_to_s;
		}
	}
	else {
		res = a_to_s + s;
	}

	cout << res << endl;

	return 0;
}
0