Source of the problem
http://ac.jobdu.com/problem.php?pid=1014
Problem Description
The number of candidates to enter N (0 < N < 1000), the number of questions m (0 < M < = 10), the bar (positive integer) G, followed by the 1th question to the question of the positive integer score, followed by each candidate's ticket number (the length of the string not exceeding 20), the total number of topics m, to And the question number of the M-question (question number from 1 to m).
Problem Analysis
directly to the processing, calculate the total score of each student, more than the bar is added to the structure array, the last array sort, the output can be.
Note The custom CMP comparison function is written as: Returns True if the former is in front.
Reference Code
////Created by Alvinzh on 2017/5/24.//Copyright (c) alvinzh. All rights reserved.//#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespaceStd;typedefstructstu{Charid[ -]; intMark;}; Stu s[1005];BOOLcmpConstStu &a,ConstStu &b) { if(a.mark!=B.mark)returnA.mark>B.mark; Else returnstrcmp (A.id,b.id) <0;}intMain () {intn,m,g; intgrade[ One]; intCount; while(~SCANF ("%d", &n) &&n!=0) {Count=0; scanf ("%d%d",&m,&G); for(intI=1; i<=m;i++) scanf ("%d",&Grade[i]); Charsid[ -]; intm; intQid; intSUMG; for(intI=1; i<=n;i++) {SUMG=0; scanf ("%s%d",&sid,&m); for(intj=1; j<=m;j++) {scanf ("%d",&Qid); SUMG+=Grade[qid]; } if(sumg>=G) {strcpy (S[COUNT].ID,SID); S[count]. Mark=SUMG; Count++; }} sort (S,s+count,cmp); printf ("%d\n", Count); for(intI=0; i<count;i++) printf ("%s%d\n", S[i].id,s[i]. Mark); }}
Alvinzh
Source: http://www.cnblogs.com/AlvinZH/
I Github:https://github.com/pacsiy/jobdu
The copyright belongs to the author Alvinzh and blog Park all, welcome reprint and Commercial, but without the consent of the author must retain this paragraph statement, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.
Title 1014: Ranking (structure sort)