-
Title Description:
-
today's on-machine exam Although there is a real-time ranklist, but the above ranking is based on the completion of the number of questions sorted, not considering the score of each question, so not the final ranking. Given the admission fraction, please write the program to find the final pass test takers and print their scores in descending order.
-
Input:
-
The test input contains information about several exam fields. The 1th line of each exam information gives the number of candidates N (0 < N < 1000), the number of questions M (0 < M < = 10), the bar (positive integer) G, and the 2nd row gives the positive integer score for the 1th to the M question; The following N lines, each line gives a candidate's ticket number (length does not More than 20 strings), the total number of topics solved by the student m, and the question number of the M-Question (subject number from 1 to m).
When the number of candidates read is 0 o'clock, the input is completed and the exam is not processed.
-
Output:
-
For each exam, the number of candidates in the 1th line of the first output of no less than a score of n, and then n rows of scores from high to low output on the test number and scores of candidates, between 1 spaces separated. If multiple candidates have the same score, they will be output in ascending order of their test number.
-
Sample input:
-
4 5 2510 15cs004 3 5 1 3cs003 5 2 4 1 3 5cs002 2 1 2cs001 3 2 3 Wuyi 2 4010 30cs001 1 3 000001 0cs000000000000000002 2 1 20
-
Sample output:
-
3cs003 60cs001 37cs004 3701cs000000000000000002 20
-
Source:
- 2005 Zhejiang University computer and software engineering research on the real problem of life test
Code:
#include <iostream>#include<string>#include<vector>#include<algorithm>using namespacestd;structstudent{stringID; intSolvenum; Vector<int>Problemid; intscore;}; intCalculatescore (vector<int> &problemID,vector<int> &Problemscore) { intAnswer=0; for(unsignedintI=0; I<problemid.size (); + +i) {Answer+=problemscore[problemid[i]-1];//note here to subtract 1 } returnanswer;} BOOLCMP (Student a,student b) {if(a.score!=B.score)returnA.score>B.score; returna.id<=b.ID;} intMain () {Student arr[1010]; intn,m,g; Vector<int>Problemscore; while(cin>>N) { if(n==0) Break; Problemscore.clear (); for(intI=0; i<n;++i) arr[i].problemid.clear (); CIN>>M>>G; for(intI=0; i<m;++i) { intTmpscore; CIN>>Tmpscore; Problemscore.push_back (Tmpscore); } for(intI=0; i<n;++i) {cin>>arr[i].id; CIN>>Arr[i].solvenum; for(intj=0; j<arr[i].solvenum;++j) { intTmpid; CIN>>Tmpid; Arr[i].problemid.push_back (TMPID); } Arr[i].score=Calculatescore (Arr[i].problemid,problemscore); } sort (Arr,arr+n,cmp); intStudentcount=0; for(intI=0; i<n;++i)if(arr[i].score>=G)++Studentcount; cout<<studentCount<<Endl; for(intI=0; i<studentcount;++i) cout<<arr[i].ID<<" "<<arr[i].score<<Endl; } return 0;} /************************************************************** problem:1014 User:lcyvino language:c++ Re sult:accepted time:790 Ms memory:1668 kb****************************************************************/
Title 1014: Ranking