結果

問題 No.126 2基のエレベータ
コンテスト
ユーザー tottoripaper
提出日時 2015-03-04 17:05:34
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 416 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 418 ms
コンパイル使用メモリ 50,712 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-09 11:28:30
合計ジャッジ時間 895 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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);
}
0