1137 Final Grading
中文版。
1080 MOOC期终成绩
1 #include<iostream> 2 #include<vector> 3 #include<unordered_map> 4 #include<algorithm> 5 #include<cmath> 6 using namespace std; 7 8 struct Student { 9 string id; 10 int GP,GM,GF,G; 11 bool flag; 12 }; 13 14 bool cmp(const Student& a,const Student& b) { 15 if(a.flag != b.flag) return a.flag > b.flag; 16 else if(a.G != b.G) return a.G > b.G; 17 else return a.id < b.id; 18 } 19 int main() { 20 int p,m,n,score,num = 0; 21 cin>>p>>m>>n; 22 vector<Student> vs; 23 unordered_map<string,int> mp; 24 string id; 25 for(int i = 0; i < p; ++i) { 26 cin>>id>>score; 27 if(score >= 200) { 28 vs.push_back({id,score,-1,-1,-1,false}); 29 mp[id] = num++; 30 } 31 } 32 for(int i = 0; i < m; ++i) { 33 cin>>id>>score; 34 if(mp.count(id) == 1) 35 vs[mp[id]].GM = score; 36 } 37 for(int i = 0; i < n; ++i) { 38 cin>>id>>score; 39 if(mp.count(id) == 1) { 40 vs[mp[id]].GF = score; 41 if(vs[mp[id]].GM > score) 42 vs[mp[id]].G = round(vs[mp[id]].GM*0.4+score*0.6); 43 else 44 vs[mp[id]].G = score; 45 if(vs[mp[id]].G >= 60) 46 vs[mp[id]].flag = true; 47 } 48 } 49 sort(vs.begin(),vs.end(),cmp); 50 for(int i = 0 ; i < vs.size(); ++i) { 51 if(vs[i].flag == false) break; 52 printf("%s %d %d %d %d\n",vs[i].id.c_str(),vs[i].GP,vs[i].GM,vs[i].GF,vs[i].G); 53 } 54 return 0; 55 }


浙公网安备 33010602011771号