//水题
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 105;
int a[7], b[7];
int store[maxn];
void showa()
{
for (int i = 0; i < 7; i++) cout << a[i] << " ";
cout << endl;
}
void showb()
{
for (int i = 0; i < 7; i++) cout << b[i] << " ";
cout << endl;
}
bool check()
{
for (int i = 0; i < 7; i++)
if (b[i] < 0) return false;
return true;
}
bool GetBFromA()
{
b[6] = a[6];
for (int i = 3; i < 6; i++)
b[i] = a[i] - a[6];
b[0] = a[0] - b[3] - b[5] - b[6];
b[1] = a[1] - b[3] - b[4] - b[6];
b[2] = a[2] - b[4] - b[5] - b[6];
return (check());
}
int sumb()
{
int sum = 0;
for (int i = 0; i < 7; i++) sum += b[i];
return sum;
}
int main()
{
int t, cnt;
int N;
cin >> t;
while (t--)
{
cnt = 0;
cin >> N;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < 7; j++) cin >> a[j];
// showa();
GetBFromA();
// showb();
if (check())
{
store[cnt] = sumb(); cnt++;
// cout << "test " << endl;
}
else
continue;
}
sort(store, store+cnt);
cout << store[--cnt] << endl;
}
return 0;
}
HDU - 6106 Classes
最新推荐文章于 2024-05-21 23:16:53 发布