結果

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

ソースコード

diff #

#include<iostream>
#include<cstdlib>

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

	std::cin >> a >> b >> s;

	int dist_a = std::abs(a - s),
		dist_b = std::abs(b - s);
	
	int ans;
	if (dist_a < dist_b || dist_a == dist_b || s == 1) {
		ans = dist_a + s;
	} else {
		ans = dist_b;
		if (dist_a < s - 1) ans += dist_a;
		else ans += s;
		ans += a;
	}

	std::cout << ans << std::endl;
}
0