結果

問題 No.966 引き算をして門松列(その1)
ユーザー 👑 zeronosu77108zeronosu77108
提出日時 2020-01-13 22:09:25
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,016 bytes
コンパイル時間 1,173 ms
コンパイル使用メモリ 138,220 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-07 20:13:30
合計ジャッジ時間 1,490 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <climits>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    int t;
    cin >> t;
    for (int i=0; i<t; i++) {
        int a,b,c;
        int ans = INT_MAX;
        cin >> a >> b >> c;

        if ((a<b&&c<b) || (b<a&&b<c)) {
            cout << 0 << endl;
            continue;
        }

        if (a>c) swap(a,c);
        if (a == b && a == c) {
            ans = 3;
            a--;
            c-=2;
        }
        else if (abs(b-a) < abs(c-b) + (b-1==a? 1 : 0)) {
            ans = abs(b-a) + 1;
            b = a-1;
        } else {
            ans = abs(c-b) + 1;
            c = b-1;
            if (a == c) c--,ans++;
        }

        if (a<=0 || b<=0 || c<=0) ans = -1;
        cout << ans << endl;
    }
}
0