結果

問題 No.2110 012 Matching
ユーザー ruthenruthen
提出日時 2022-10-28 21:41:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 1,100 bytes
コンパイル時間 2,640 ms
コンパイル使用メモリ 205,588 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 04:32:45
合計ジャッジ時間 5,330 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 47 ms
4,380 KB
testcase_02 AC 119 ms
4,376 KB
testcase_03 AC 79 ms
4,380 KB
testcase_04 AC 158 ms
4,376 KB
testcase_05 AC 112 ms
4,376 KB
testcase_06 AC 107 ms
4,380 KB
testcase_07 AC 179 ms
4,376 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 27 ms
4,376 KB
testcase_10 AC 178 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

void solve() {
    V<ll> D(3);
    rep(i, 3) cin >> D[i];
    show(D);
    V<pair<int, int>> P = {{0, 1}, {0, 2}, {1, 1}, {2, 2}};
    ll ans = 0;
    do {
        // show(P);
        auto DC = D;
        ll cur = 0;
        for (auto [a, b] : P) {
            if (a != b) {
                ll mn = min(D[a], D[b]);
                ll s = (a + b) % 3;
                cur += mn * s;
                D[a] -= mn;
                D[b] -= mn;
            } else {
                ll c = D[a] / 2;
                ll s = (a + b) % 3;
                cur += c * s;
                D[a] -= c * 2;
            }
        }
        ans = max(ans, cur);
        D = DC;
    } while (next_permutation(P.begin(), P.end()));
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) solve();
    return 0;
}
0