您的位置:首页 > 编程语言

HDU - 6106 Classes

2017-08-20 21:43 429 查看
//水题
#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ACM 算法 编程 HDU