#include #include #include //#include #include #include #ifdef L_JUDGE #pragma warning(disable:4996) #endif using namespace std; const int MAXN=1005; typedef pair pii; pii pos[30],neg[30]; int pos_cnt,neg_cnt; bool cmp1(pii x,pii y){ return x.first<=y.first; } bool cmp2(pii x,pii y){ return x.first>=y.first; } int main(){ #ifdef L_JUDGE freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); #endif int T,N; scanf("%d",&T); for(int ti=1;ti<=T;ti++){ scanf("%d",&N); pos_cnt=0; neg_cnt=0; for(int i=0;i=0){ pos[pos_cnt].first=v; pos[pos_cnt++].second=c; }else{ neg[neg_cnt].first=v; neg[neg_cnt++].second=c; } } sort(pos,pos+pos_cnt,cmp1); sort(neg,neg+neg_cnt,cmp2); int sum=0; int ans=0; int pnum=0; for(int pi=0;pi