結果

問題 No.965 門松列が嫌い
ユーザー kya_skikya_ski
提出日時 2020-01-13 20:40:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 783 bytes
コンパイル時間 2,077 ms
コンパイル使用メモリ 195,372 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 13:11:54
合計ジャッジ時間 2,802 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

long long mid(long long a, long long b, long long c) {
    return a+b+c-max({a, b, c})-min({a, b, c});
}

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    if (mid(a, b, c) == b) { cout << 0 << endl; return 0; }
    if (min({a, b, c}) == b) {
        long long d = abs(b-min(a, c)), e = abs(a-c);
        cout << min(d, e) << endl;
    } else {
        long long d = abs(b-max(a, c)), e = abs(a-c);
        cout << min(d, e) << endl;
    }
}
0