結果

問題 No.966 引き算をして門松列(その1)
ユーザー tooftoof
提出日時 2020-01-13 21:44:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 907 bytes
コンパイル時間 1,863 ms
コンパイル使用メモリ 200,020 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 15:59:12
合計ジャッジ時間 2,535 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

int main() {
  cin.tie(0); ios::sync_with_stdio(false);

  ll n;
  cin >> n;
  vl a(n), b(n), c(n);
  rep(i, n) {
    cin >> a[i] >> b[i] >> c[i];
  }

  rep(i, n) {
    if (b[i] < 3) {
      cout << -1 << endl;
      continue;
    }
    ll cnt = 0;
    if (a[i] >= b[i]) {
      cnt += a[i]-(b[i]-1);
      a[i] = b[i]-1;
    }
    if (c[i] >= b[i]) {
      cnt += c[i]-(b[i]-1);
      c[i] = b[i]-1;
    }

    if (a[i] == c[i]) {
      cnt++;
    }
    cout << cnt << endl;
  }
}
0