結果

問題 No.2110 012 Matching
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-05-21 13:48:26
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 2,391 ms
コンパイル使用メモリ 200,672 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-20 18:11:49
合計ジャッジ時間 5,356 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
long long calc(long long a, long long b, long long c) {
    long long res = b + 2 * c;
    c = max(0LL, c - a);
    res -= 3 * (c / 2);
    res -= 3 * (c % 2);
    return res;
}
int main() {
    fast_io();
    int t;
    cin >> t;
    for (; t--;) {
        long long a, b, c;
        cin >> a >> b >> c;
        if ((a + b + c) % 2 == 0) {
            cout << calc(a, b, c) << "\n";
        } else {
            cout << max({calc(a - 1, b, c), calc(a, b - 1, c),
                         calc(a, b, c - 1)})
                 << "\n";
        }
    }
}
0