看到25分的就放弃Java吧,铁定有超时的
#include
#include
#include
#include
#include
#include
using namespace std;
struct node {
string name;
int gp, gm, gf, g;
};
map<string, int> idx;
vector<node> v, ans;
bool cmp(node a, node b) {
if (a.g != b.g) return a.g > b.g;
else return a.name < b.name;
}
int main() {
int p, m, n, score, count = 1;//count作为编号
scanf("%d%d%d", &p, &m, &n);
string s;
for (int i = 0; i < p; i++) {
cin >> s >> score;
if (score >= 200) {//把编程分数低于200的过滤掉
idx[s] = count++;
v.push_back(node{ s, score, -1, -1, 0 });
//最新入容器的其他分数都是-1,方便后面输出
}
}
for (int i = 0; i < m; i++) {
cin >> s >> score;
if (idx[s] != 0) {
v[idx[s] - 1].gm = score;
}
}
for (int i = 0; i < n; i++) {
cin >> s >> score;
if (idx[s] != 0) {
int temp = idx[s] - 1;
v[temp].gf = v[temp].g = score;//这里道理同上,这样写的方式确实比较省事
if (v[temp].gm > v[temp].gf) {
v[temp].g = int(0.4 * v[temp].gm + 0.6 * v[temp].gf + 0.5);
}
}
}
for (int i = 0; i < v.size(); i++) {
if (v[i].g >= 60) {
ans.push_back(v[i]);
}
}
sort(ans.begin(), ans.end(), cmp);
for (int i = 0; i < ans.size(); i++) {
printf("%s %d %d %d %d\n", ans[i].name.c_str(), ans[i].gp, ans[i].gm, ans[i].gf, ans[i].g);
}
}