题意:自己看。
思路:硬干呗, 我们写了很多判断,队友主笔。正确率不高,可能很多人都取巧了, 包括我们一开始也是这种心理和做法。但是把所有值都求出来判断是否合法(不小于0)是最稳的做法,其他多余的判断是我们想到就加的,反正不会影响正确性。水题不多说。
#include <cstring>
#include <cstdio>
#include <iostream>
#include <string>
#include <climits>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
#define MAXN_NUM 0x3f3f3f3f
#define EPS 1e-6
#define DGA(x)
#define DFA(x)
#define PRT(x,a) printf("%s%d%s\n",a,x,a)
#define TEST(x) printf("---------test %c---------\n",x+'A')
#define Fin(i,f,t) for(int i=f;i<=t;++i)
#define Fde(i,f,t) for(int i=f;i>=t;--i)
#define SfI(x) scanf("%d",&x)
#define SfLL(x) scanf("%lld",&x)
#define SfD(x) scanf("%lf",&x)
#define SfC(x) scanf("%c",&x)
#define SfS(x) scanf("%s",x)
#define MAXN 6
int a,b,c,ab,ac,bc,abc;
int ta,tb,tc,tab,tac,tbc,tabc;
bool Judge(){
ta = a; tb = b; tc = c;tabc = abc;
tab = ab; tbc = bc; tac = ac;
tab -= abc; if(tab < 0) return false;
tac -= abc; if(tac < 0) return false;
tbc -= abc; if(tbc < 0) return false;
ta -=(ab + ac - abc); if(ta < 0) return false;
tb -=(ab + bc - abc); if(tb < 0) return false;
tc -=(ac + bc - abc); if(tc < 0) return false;
if(ab > min(a,b)) return false;
if(ac > min(a,c)) return false;
if(bc > min(b,c)) return false;
if(abc > min(min(ab,ac),bc)) return false;
if(abc < ac+ab-a) return false;
if(abc < bc+ab-b) return false;
if(abc < ac+bc-c) return false;
//printf("%d %d %d %d %d %d %d\n",ta,tb,tc,tab,tbc,tac,tabc);
if (a+b<ab) return false;
if (a+c<ac) return false;
if (b+c<bc) return false;
if (a+b+c<abc) return false;
if (ab+bc<abc) return false;
if (ab+ac<abc) return false;
if (bc+ac<abc) return false;
return true;
}
int main(void){
DFA(freopen("D:\\test.txt","r",stdin));
//freopen("D:\\tsst.txt","w",stdout);
int T;
SfI(T);
Fin(t,1,T){
int N,Max = 0;
SfI(N);
Fin(i,1,N){
scanf("%d%d%d%d%d%d%d",&a,&b,&c,&ab,&bc,&ac,&abc);
if(!Judge()) continue;
Max = max(Max,ta+tb+tc+tab+tac+tbc+tabc);
}
printf("%d\n",Max);
}
return 0;
}