結果

問題 No.126 2基のエレベータ
ユーザー a
提出日時 2015-01-13 23:58:13
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 401 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 58,648 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 05:44:37
合計ジャッジ時間 1,356 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int a, b, s;

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

	int move;

	if (s == 1) {
		move = abs(a - s) + s;
	} else if (abs(a - s) <= abs(b - s)) {
		move = abs(a - s) + s;
	} else {
		move = abs(b - s);

		if (a != 0) {
			move += abs(s - a) + a;
		} else {
			move += s - 1 + 2;
		}
	}

	cout << move << endl;
	return 0;
}
0