結果

問題 No.126 2基のエレベータ
ユーザー mayoko_
提出日時 2015-01-13 23:33:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 72,916 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 05:28:32
合計ジャッジ時間 1,385 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define INF 1000000000

using namespace std;
typedef long long ll;

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