結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
くれちー
|
| 提出日時 | 2017-01-07 16:30:02 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 318 bytes |
| コンパイル時間 | 613 ms |
| コンパイル使用メモリ | 21,248 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-17 16:17:46 |
| 合計ジャッジ時間 | 1,793 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 4 |
コンパイルメッセージ
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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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 = 0;
if (s == 1) ans = da + 1;
else if (da <= db) ans = da + s;
else {
ans += db + s - 1;
da = abs(1 - a);
ans += da + 1;
}
printf("%d\n", ans);
return 0;
}
くれちー