結果

問題 No.126 2基のエレベータ
ユーザー masa
提出日時 2015-05-25 00:03:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 374 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 60,268 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 08:09:10
合計ジャッジ時間 1,369 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	cin >> a >> b >> s;

	int ans;

	if (s == 1 || abs(a - s) <= abs(b - s)) {
		ans = abs(a - s) + s;
	} else {
		ans = abs(b - s) + min(abs(s - a) + a, s - 1 + a - 1 + 1);
	}
	cout << ans << endl;
	return 0;
}
0