結果

問題 No.126 2基のエレベータ
ユーザー くれちー
提出日時 2017-01-07 16:14:47
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 253 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 21,120 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-17 16:17:36
合計ジャッジ時間 1,176 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d %d %d", &a, &b, &s);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int main() {
	int a, b, s;
	scanf("%d %d %d", &a, &b, &s);

	int da = abs(s - a), db = abs(s - b);
	int ans;

	if (da <= db) ans = da + s;
	else ans = da + db + (s - 1) * 2 + 1;

	printf("%d\n", ans);
	return 0;
}
0