結果

問題 No.126 2基のエレベータ
ユーザー bal4u
提出日時 2019-04-12 14:08:28
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 376 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 28,032 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 01:57:45
合計ジャッジ時間 1,265 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.126 2基のエレベータ
// 2019.4.12 bal4u

#include <stdio.h>

#define ABS(a)  ((a)>=0?(a):-(a))

int main()
{
	int A, B, S, a, b, ans;
	scanf("%d%d%d", &A, &B, &S);
	a = ABS(A - S), b = ABS(B - S);
	if (S == 1) ans = a + 1;
	else if (a <= b) ans = a + S;
	else {
		if (S > A) ans = b + S;
		else ans = A + b + S - 1;
	}
	printf("%d\n", ans);
	return 0;
}
0