For MOOC in Chinese Universities( http://www.icourse163.org/ )Students studying the "data structure" course who want to obtain a qualification certificate must first obtain an online programming homework score of no less than 200 points, and then obtain a total score of no less than 60 points (out of 100). The calculation formula of the total score is G=(G mid − term) × 40%+G final × 60%), such as G mid − term > G final; Otherwise, the general comment G is g final. Here, G mid − term and G final are the students' midterm and final scores respectively.

The problem now is that each exam produces an independent report card. Please write a program to combine different transcripts into one.

Input format:

Input: three integers are given in the first line, which are P (the number of students who have done online programming homework), M (the number of students who have taken the midterm exam) and N (the number of students who have taken the final exam). Each number does not exceed 10000.

Next, there are three inputs. The first block contains P online programming scores Gp; The second block contains M mid-term test scores G mid − term; The third block contains N final exam scores G final. Each grade occupies one line in the form of student number score. The student number shall be English letters and numbers with no more than 20 characters; The score is a non negative integer (the maximum total score for programming is 900, and the maximum score at the end of the period is 100).

Output format:

Print out the list of students who have obtained the qualification certificate. One line for each student in the format:

Student ID G p G mid − term G final G

If some scores do not exist (for example, someone did not take the mid-term exam), output "− 1" in the corresponding position. The output order is decreasing according to the total evaluation score (rounded to the nearest integer). If there is juxtaposition, it will be increased by student number. Ensure that the student number is not repeated and there is at least one qualified student.

Input example:

6 6 7

01234 880

a1903 199

ydjh2 200

wehu8 300

dx86w 220

missing 400

ydhfu77 99

wehu8 55

ydjh2 98

dx86w 88

a1903 86

01234 39

ydhfu77 88

a1903 66

01234 58

wehu8 84

ydjh2 82

missing 99

dx86w 81

Output example:

missing 400 -1 99 99

ydjh2 200 98 82 88

dx86w 220 88 81 84

wehu8 300 55 84 84

My Answer Code:

/* Author:Albert Tesla Wizard Time:2021/7/28 12:27 */ #include<bits/stdc++.h> using namespace std; struct student { string name; int pscore; //Set the default value of midterm and final grades to - 1 int mscore=-1; int nscore=-1; int score; }; bool Temp(student A,student B) { if(A.score>B.score)return true; else if(A.score==B.score&&A.name<B.name)return true; else return false; } void solve(int p,int m,int n) { map<string,int>a; string s; int pscore,mscore,nscore,score; vector<student>b; student temp,temp1; //Programming score input for(int i=0;i<p;i++){cin>>s>>pscore;a[s]=pscore;} //Interim grade input for(int i=0;i<m;i++) { cin>>s; cin>>mscore; if(a[s]>=200)//Only when the programming score is higher than 200 points can it be entered { temp.name=s; temp.mscore=mscore; temp.pscore=a[s]; b.push_back(temp); } } //Final grade input for(int i=0;i<n;i++) { cin>>s>>nscore; if(a[s]>=200)//Only when the programming score is higher than 200 points can it be entered { bool flag=false; for(int j=0;j<b.size();j++) { if(b[j].name==s){b[j].nscore=nscore;flag=true;break;} } if(!flag) { temp1.name=s; temp1.nscore=nscore; temp1.pscore=a[s]; b.push_back(temp1); } } } //Total score calculation for(int i=0;i<b.size();i++) { float Score=b[i].mscore*0.4+b[i].nscore*0.6; if(b[i].mscore>b[i].nscore) { if(Score-int(Score)>=0.5)b[i].score=int(Score)+1; else b[i].score=int(Score); } else b[i].score=b[i].nscore; } //Ranking Ranking sort(b.begin(),b.end(),Temp); //Ranking table output for(int i=0;i<b.size();i++) { if(b[i].score>=60)cout<<b[i].name<<" "<<b[i].pscore<<" "<<b[i].mscore<<" "<<b[i].nscore<<" "<<b[i].score<<'\n'; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int p,m,n; cin>>p>>m>>n; solve(p,m,n); return 0; }