题意:
给你n1,n2,n3个2,3,4。问你最多能凑出来多少个10?
思路:
显然只有442 433 3322 4222 22222五种凑法,注意到3一定是成对出现,所以把3的数量除以2,变为6的数量,并优先考虑6.
具体见注释
// Decline is inevitable, romance will last forever.
//ARC126A-make 10
//#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cstdio>
using namespace std;
#define mst(a, x) memset(a, x, sizeof(a))
#define INF 0x3f3f3f3f
#define P 998244353
#define int long long
const int maxn = 2e5 + 10;
const int maxm = 3e5*4 + 10;
void solve() {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
b >>= 1;
int d = a + c/2;
if(b >= c + a/2) { //若6的数量比2的数量/2和4的数量加起来还多,则直接输出
cout << c + a/2 << '\n';
return;
}
ans = b; //下面考虑6能够用完的情况 ans先等于6的数量
if(c >= ans) c-= ans; //如果4的数量比6的数量多 则仅用4就能凑出来b个10
else a -= 2*(ans-c),c = 0; //否则把所有4都用完,再用掉一部分2,凑出b个10
if(c >= a*2) { //如果此时还能凑出来442 则凑完 这时仅剩下4了 凑不出10了
ans += a;
}
else {
int tmp = c/2; //否则先把442凑完
c -= tmp*2, a-=tmp;
ans += tmp;
ans += (c*4+a*2)/10; //此时剩下的4数量为0or1,2可能剩下很多
}
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// int T; scanf("%d", &T); while(T--)
int T; cin >> T; while(T--)
solve();
return 0;
}