#include #include #include #include using namespace std; typedef tuple T3;//Solve,-penalty,teamid priority_queue Univ[100001]; int Univteam[100001]; typedef tuple T5;//Solve,-univteam,-penalty,univid,teamid priority_queue que; int main(){ int N,K; cin>>N>>K; for(int i=0;i>S>>P>>U; Univ[U].emplace(S,-P,i); } for(int i=0;i<=100000;i++){ if(!Univ[i].empty()){ auto t=Univ[i].top(); Univ[i].pop(); que.emplace(get<0>(t),Univteam[i]--,get<1>(t),i,get<2>(t)); } } for(int i=0;i(t)<(t); if(!Univ[univid].empty()){ auto t=Univ[univid].top(); Univ[univid].pop(); que.emplace(get<0>(t),Univteam[univid]--,get<1>(t),i,get<2>(t)); } } return 0; }