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