#define _USE_MATH_DEFINES #pragma region include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //// //#include // #pragma endregion //#include ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)4e18+20; const LD PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; void solve(){ int N; cin>>N; map memo; vector word; while(N--){ int no,M,S; cin>>no>>M>>S; while(M--){ string str; cin>>str; if( memo.find(str) != memo.end() ){ memo[str]-=S; }else{ memo[str]-=S; word.push_back( str ); } } } sort(word.begin(),word.end()); map::iterator itr,end; itr = memo.begin(); end = memo.end(); vector< vector > list; for(;itr!=end;++itr){ vector temp(2); temp[0] = itr->second; temp[1] = lower_bound(word.begin(),word.end(),itr->first)-word.begin(); list.push_back( temp ); } sort(list.begin(),list.end()); int size = list.size(); for(int i=0;i