#include #include #include #include #include using namespace std; struct ICPC { int s, p, u, num; bool operator<(const ICPC& right) const { if (u != right.u) return uright.s; return p> n >> k; vector data; for (int i = 0; i < n; i++) { int s, p, u; cin >> s >> p >> u; ICPC icpc = { s,p,u,i }; data.push_back(icpc); } sort(data.begin(), data.end()); vector > pe_sort[11]; for (int j = 0; j < data.size(); j++) { long long penalty = data[j].p + Univ[data[j].u] * (long long)1e7; pe_sort[data[j].s].push_back(make_pair(penalty, data[j].num)); Univ[data[j].u]++; } for (int i = 0; i < 11; i++) { sort(pe_sort[i].begin(), pe_sort[i].end()); } int cnt = 0; for (int i = 10; i >= 0; i--) { for (int j = 0; j < pe_sort[i].size(); j++) { cout << pe_sort[i][j].first << endl; cnt++; if (cnt == k) return 0; } } return 0; }