結果

問題 No.126 2基のエレベータ
ユーザー h_noson
提出日時 2016-02-16 19:50:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 479 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 57,360 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-22 07:18:12
合計ジャッジ時間 1,440 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

#define REP(i,s,e) for (int i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)

int main() {
    int a, b, s, ans;
    cin >> a >> b >> s;
    int da = abs(s - a);
    int db = abs(s - b);

    if (da <= db)
        ans = da + s;
    else if (a == 0)
        ans = db + (s-1) + 2;
    else if (b >= abs(a-b))
        ans = db + abs(a-b) + a;
    else
        ans = db + (s-1) + a;
    cout << ans << endl;
    return 0;
}

0