結果

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

ソースコード

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;
		if (s < a) {
			res += s - 1 + a;
		}
		else {
			res += s;
		}
	}
	else {
		if (a < s) {
			res = a_to_s + s;
		}
		else {
			res = a;
		}
	}

	cout << res << endl;

	return 0;
}
0