結果

問題 No.966 引き算をして門松列(その1)
ユーザー konchanksukonchanksu
提出日時 2020-04-21 00:22:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 66,932 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 01:06:31
合計ジャッジ時間 1,172 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int t, i, j, k, ans;
int main(){
    cin >> t;
    long long a[t], b[t], c[t];
    for(i = 0; i < t; i++) cin >> a[i] >> b[i] >> c[i];
    for(i = 0; i < t; i++){
        ans = 0;
        if(a[i] == c[i]) {ans += 1; a[i] -= 1;}
        if(a[i] == 0){ans = -1;}
        else{
            if(a[i] > c[i]) {j = a[i]; a[i] = c[i]; c[i] = j;}
            if(a[i] <= b[i] && c[i] >= b[i]) {
                if(b[i] <= 1) ans = -1;
                else if(b[i] == 2 && (a[i] != b[i] && c[i] != b[i])) ans = -1;
                else if(b[i] - a[i] == 1) ans += 2;
                else if(a[i] == 1) ans += c[i] - b[i] + 1; 
                else ans += min(c[i] - b[i] + 1, b[i] - a[i] + 1);
            }
        }
        cout << ans << endl;
    }
    return 0;
}
0