結果

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

ソースコード

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) {
		ans = dist_a + s;
	} else {
		ans = dist_b + s - 1;
		ans += std::abs(1 - a) + 1;
	}

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