結果
| 問題 |
No.2110 012 Matching
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-28 22:50:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 2,000 ms |
| コード長 | 1,358 bytes |
| コンパイル時間 | 1,904 ms |
| コンパイル使用メモリ | 195,684 KB |
| 最終ジャッジ日時 | 2025-02-08 14:51:37 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
#include <algorithm>
#include <bits/stdc++.h>
#ifdef SHO_LOCAL
#include "debug.h"
#else
#define debug(...) \
{}
#endif
using namespace std;
void solution() {
long long A, B, C;
cin >> A >> B >> C;
long long a = A, b = B, c = C;
long long ans = 0;
auto Reset = [&]() {
ans = 0;
a = A, b = B, c = C;
};
auto cc = [&]() {
ans += c / 2;
c = c % 2;
};
auto ac = [&]() {
long long t = min(a, c);
ans += t * 2;
a = max(0LL, a - t);
c = max(0LL, c - t);
};
auto ab = [&]() {
long long t = min(a, b);
ans += t;
a = max(0LL, a - t);
b = max(0LL, b - t);
};
auto bb = [&]() {
ans += b / 2 * 2;
b = b % 2;
};
long long res = 0;
vector<int> p(4);
iota(p.begin(), p.end(), 0);
do {
Reset();
for (int i = 0; i < 4; i++) {
int j = p[i];
if (j == 0)
ab();
else if (j == 1)
ac();
else if (j == 2)
bb();
else
cc();
}
res = max(res, ans);
} while (next_permutation(p.begin(), p.end()));
cout << res << '\n';
}
int main() {
iostream::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int TT;
cin >> TT;
for (int tc = 1; tc <= TT; tc++) {
// cout << "Case #" << tc << ": " << solution() << '\n';
solution();
}
return 0;
}