結果

問題 No.126 2基のエレベータ
ユーザー tsukiotsukio
提出日時 2016-03-05 01:25:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 404 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 58,880 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 19:50:31
合計ジャッジ時間 1,327 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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