結果
| 問題 |
No.2110 012 Matching
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-28 21:41:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 166 ms / 2,000 ms |
| コード長 | 1,100 bytes |
| コンパイル時間 | 2,060 ms |
| コンパイル使用メモリ | 199,804 KB |
| 最終ジャッジ日時 | 2025-02-08 14:16:42 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
#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;
}