結果

問題 No.126 2基のエレベータ
ユーザー GOTKAKO
提出日時 2025-07-12 20:27:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 389 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 191,236 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-12 20:27:43
合計ジャッジ時間 3,012 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int a,b,s; cin >> a >> b >> s;
    if(abs(a-s) <= abs(b-s)) cout << abs(a-s)+s << endl;
    else if(s == 1) cout << abs(a-s)+s << endl;
    else if(a == 0) cout << abs(b-s)+s-1+abs(a-1)+1 << endl;
    else cout << abs(b-s)+min(s-1+abs(a-1)+1,abs(s-a)+a) << endl; 
}
0