Title Description
Today's examination on although there are real-time Ranklist, but only the top ranked according to the number of issues to sort completed, without considering the score for each question, it is not the final rankings. Given admission, you write a program to find the final score by the candidates, and their performance print in descending order.
Entry
The input contains several test information field test. Examination first information line per field gives the number of candidates N (0 <N <1000) , exam number M (0 <M <= 10 ), the score line (positive integer) G; the second line sorting is given to the first question positive integer value of m question; the N rows, each row is given a ticket number of candidates (the string length does not exceed 20), the total number m sOLVING subject, title, and number of questions that m (subject number from 1 to M). When the number of candidates read as 0, the input end of the exam not be processed.
Export
For each test, the number of candidates in the first row of the first line of the fractional output of not less than n, then n row by score in descending output on the score line candidate number candidates, separated by a space therebetween. If the same score more than the candidates, press their candidate number ascending output
Sample input
4 5 25
10 10 12 13 15
CS004 3 5 1 3
CS003 5 2 4 1 3 5
CS002 2 1 2
CS001 3 2 3 5
1 2 40
10 30
CS001 1 2
2 3 20
10 10 10
CS000000000000000001 0
CS000000000000000002 2 1 2
0
Sample Output
3 CS003 60 CS001 37 CS004 37 0 1 CS000000000000000002 20
1 #include<stdio.h> 2 #include<malloc.h> 3 #include<algorithm> 4 #include<string.h> 5 using namespace std; 6 7 typedef struct stu{ 8 char num_P[21]; 9 int tol_slv; 10 int flag_slv[12]; 11 int getscore; 12 }stu; 13 bool cmp(stu s1,stu s2){ 14 int t=strcmp (s1.num_P, s2.num_P); 15 IF (s1.getscore == s2.getscore) return T < 0 ; // return T <0 it means that the ascending side Hui string comparison 16 the else return s1.getscore > s2.getscore; . 17 } 18 is int main () { . 19 int num_P; 20 is the while (Scanf ( " % D " , & num_P) && num_P> 0 && num_P < 1000 ) { 21 is int num_Q, num_G; 22 is int Pass = 0 ; / / record number of people over the line 23 Scanf ( " % D% D " , & num_Q, & num_G); 24 int * Q_ary = ( int *) the malloc (num_Q * the sizeof ( int )); 25 for ( int I = 0 ; I <num_Q; I ++) { / / read each question score 26 is Scanf ( " % D " , & Q_ary [I + . 1 ]); // with flag_slv [] align 27 } 28 STU * Student = (STU *) the malloc ( the sizeof (STU) * num_P); 29 for ( int I = 0 ; I <num_P; I ++) { // for each student data initialization 30 Scanf ( " % S% D " , Student [I] .num_P, & Student [I] .tol_slv); // Science No. and the total number of questions to make 31 is for ( int J = 0 ; J <Student [I] .tol_slv; J ++ ) { 32 int POS; 33 is Scanf ( " % D " , & POS); 34 is Student [I] .flag_slv [POS] = . 1 ; // edit position to make the title 35 } 36 } 37 [ for ( int I = 0 ; I <num_P; I ++) { // each traverse 38 is Student [I] .getscore = 0 ; // initialize 39 for ( int J = 0 ; J <num_Q; J ++) { // each question to check made out yet, the score accumulated 40 IF (Student [I] .flag_slv [J + . 1 ]) { 41 is Student [I] .getscore + = Q_ary [J + . 1 ]; 42 is } 43 is 44 is } 45 IF (Student [I ] .getscore> = num_G) Pass ++ ; 46 is 47 } 48 if(pass==0) printf("0\n"); 49 else { 50 printf("%d\n",pass); 51 sort(student,student+num_P,cmp); 52 for(int i=0;i<num_P;i++){ 53 if(student[i].getscore>=num_G){ 54 printf("%s %d\n",student[i].num_P,student[i].getscore); 55 } 56 } 57 58 } 59 60 61 } 62 return 0 ; 63 }