結果

問題 No.2110 012 Matching
ユーザー a01sa01to
提出日時 2024-12-16 00:11:23
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 864 bytes
コンパイル時間 3,145 ms
コンパイル使用メモリ 245,680 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-16 00:11:31
合計ジャッジ時間 7,641 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  int t;
  cin >> t;
  while (t--) {
    ll a, b, c;
    cin >> a >> b >> c;
    auto solve = [](ll a, ll b, ll c) {
      ll res = b + 2 * c;  // ここからどれだけ減るか
      c = max(0LL, c - a);  // 0, 2 ペア
      res -= 3 * (c / 2 + c % 2);  // 2, 2 ペア -> 1, 2 ペア
      return res;
    };
    ll ans = 0;
    if ((a + b + c) % 2 != 0) {
      if (a > 0) ans = max(ans, solve(a - 1, b, c));
      if (b > 0) ans = max(ans, solve(a, b - 1, c));
      if (c > 0) ans = max(ans, solve(a, b, c - 1));
    }
    else {
      ans = solve(a, b, c);
    }
    cout << ans << endl;
  }
  return 0;
}
0