rt,代码
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
struct ss {
string s;
int v;
} a[maxn];
long long cnth, cnts;
struct hh {
string s;
int v;
} b[maxn];
bool cmp(ss x, ss y) {
return x.v > y.v;
}
bool cmp2(hh x, hh y) {
return x.v > y.v;
}
int main() {
int n, m;
cin >> n >> m;
string z, name;
long long v;
for (int i = 1; i <= n + m; i++) {
cin >> name >> z >> v;
if (z == "H") {
cnth++;
b[i].s = name;
b[i].v = v;
}
if (z == "S") {
cnts++;
a[i].s = name;
a[i].v = v;
}
}
sort(a + 1, a + cnts + 1, cmp);
sort(b + 1, b + cnth + 1, cmp2);
cout << b[3].s << endl;
for (int i = 6; i <= 9; i++) {
cout << a[i].s << endl;
}
return 0;
}