結果

問題 No.126 2基のエレベータ
ユーザー tubo28tubo28
提出日時 2015-01-14 00:00:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,576 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 66,600 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-04 06:21:55
合計ジャッジ時間 1,857 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

int const inf = 1<<26;

int main(){
    int A,B,S;
    while(cin>>A>>B>>S){
        int ans;
        if(S!=1){
            int t1 = abs(S-A) > abs(S-B) ? abs(B-S)+abs(S-1)+A : inf; // S-b>1-a>0
            int t3 = abs(S-A) > abs(S-B) ? abs(S-B)+abs(B-A)+A : inf; // S-b>A-a>0

            int t2 = abs(S-A) <= abs(S-B) ? abs(A-S)+S : inf; // S-a>0
            dump(t1,t2,t3);
            ans = min({t1,t2,t3});
            if(ans==inf) throw "";
        } else {
            ans = abs(S-A) + 1;
        }
        cout << ans << endl;
    }
}
0