結果

問題 No.126 2基のエレベータ
ユーザー aaaaaaiu
提出日時 2019-08-07 01:06:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 352 bytes
コンパイル時間 1,910 ms
コンパイル使用メモリ 193,440 KB
最終ジャッジ日時 2025-01-07 10:56:07
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int a,b,s;
    cin>>a>>b>>s;
    int da=abs(a-s);
    int db=abs(b-s);
    if (da <= db || s==1) {
        cout<<da+s<<endl;
    } else if (a!=0) {
        cout<<min(db+da+a, db+s-1+a)<<endl;
    } else {
        cout<<min(s+s, db+s-1+2)<<endl;
    }
    return 0;
}
0