#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
struct Student{
string name;
int online;
int midTerm;
int finalTerm;
int total;
Student(string s){
name = s;
online = -1;
midTerm = -1;
finalTerm = -1;
total = -1;
}
Student(){}
};
unordered_map<string,Student> students;
vector<Student> res;
bool cmp(Student a,Student b){
if(a.total != b.total)
return a.total > b.total;
return a.name < b.name;
}
int main(){
// 只有online >= 200 && total >= 60的人才计入最后排名
// online最高900 midTerm finalTerm最高100
// 最后按total从大到小排,若分数一样,则name递增排
int p,m,n;
scanf("%d%d%d",&p,&m,&n);
for(int i = 0;i < p;i++){
string s;
cin>>s;
students[s] = Student(s);
scanf("%d",&students[s].online);
}
for(int i = 0;i < m;i++){
string s;
cin>>s;
scanf("%d",&students[s].midTerm);
}
for(int i = 0;i < n;i++){
string s;
cin>>s;
scanf("%d",&students[s].finalTerm);
if(students[s].online > 900 || students[s].midTerm > 100 || students[s].finalTerm > 100)
continue;
if(students[s].midTerm > students[s].finalTerm){
students[s].total = (0.4 * students[s].midTerm + 0.6 * students[s].finalTerm) + 0.5;
}else{
students[s].total = students[s].finalTerm;
}
if(students[s].online >= 200 && students[s].total >= 60)
res.push_back(students[s]);
}
sort(res.begin(),res.end(),cmp);
for(int i = 0;i < res.size();i++){
printf("%s %d %d %d %d\n",res[i].name.c_str(),res[i].online,res[i].midTerm,res[i].finalTerm,res[i].total);
}
system("pause");
return 0;
}
PAT | A1137 Final Grading
最新推荐文章于 2022-09-30 13:46:35 发布