AcWing 3646. 分水果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
using namespace std;
int T;
int a, b, c;
int s[7][3] = {
{0, 0, 1},
{0, 1, 0},
{1, 0, 0},
{0, 1, 1},
{1, 0, 1},
{1, 1, 0},
{1, 1, 1}
};
int main() {
cin >> T;
while (T--) {
int ans = 0;
cin >> a >> b >> c;
for (int i = 1; i < 1 << 7; ++i) {
int sa = 0, sb = 0, sc = 0, cnt = 0;
for (int j = 0; j < 7; ++j) {
if (i >> j & 1) {
sa += s[j][0];
sb += s[j][1];
sc += s[j][2];
++cnt;
}
}
if (sa <= a && sb <= b && sc <= c)
ans = max(ans, cnt);
}
cout << ans << endl;
}
return 0;
}