結果

問題 No.126 2基のエレベータ
ユーザー tetsuzuki1115
提出日時 2018-01-30 02:10:15
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 938 ms
コンパイル使用メモリ 77,736 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-29 18:28:35
合計ジャッジ時間 1,877 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int A,B,S;
    cin >> A >> B >> S;
    
    int ans = 0;
    if ( abs( S-A ) <= abs( S-B ) || S == 1 ) {
        ans = abs( S-A ) + S;
    }
    else {
        ans += abs( S-B );
        ans += min( abs(S-A)+A, S-1+A );
    }
    
    cout << ans << endl;
    
    return 0;
}
0