結果
問題 | No.126 2基のエレベータ |
ユーザー |
![]() |
提出日時 | 2015-03-04 17:08:05 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 446 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 34,276 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 18:25:02 |
合計ジャッジ時間 | 1,187 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d %d %d", &A, &B, &S); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>#include <algorithm>int main(){int A, B, S;scanf("%d %d %d", &A, &B, &S);int res;if(S == 1){res = std::abs(A-S) + 1;}else if(std::abs(A-S) <= std::abs(B-S)){res = std::abs(A-S) + S;}else{res = std::abs(B-S) + S - 1 + std::abs(A-1) + 1;if(A != 0){res = std::min(res, std::abs(B-S) + std::abs(A-S) + A);}}printf("%d\n", res);}