結果
問題 |
No.126 2基のエレベータ
|
ユーザー |
![]() |
提出日時 | 2015-03-04 17:05:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 416 bytes |
コンパイル時間 | 413 ms |
コンパイル使用メモリ | 34,396 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 01:28:32 |
合計ジャッジ時間 | 1,094 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 2 |
コンパイルメッセージ
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::min(std::abs(B-S) + S - 1 + std::abs(A-1) + 1, std::abs(B-S) + std::abs(A-S) + A); } printf("%d\n", res); }