Nine degrees OJ topic 1014: Ranking

Source: Internet
Author: User

Title 1014: Ranking

time limit:1 seconds

Memory limit:32 MB

Special question: No

submitted:8130

Resolution:2417

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

Bubble Sort:

1#include <cstdio>2#include <cstring>3#include <string>4#include <queue>5#include <stack>6#include <iostream>7 using namespacestd;8 inttest[ the];9 structpeople{Ten     Charname[ -]; One     intsum; A }; -People p[1005]; - intMain () { the     //freopen ("D:\\input.txt", "R", stdin); -     intn,m,g; -      while(SCANF ("%d", &n)! =EOF) { -         if(!N) { +              Break; -         } +scanf"%d%d",&m,&g); A         inti,j; at          for(i=1; i<=m;i++){ -scanf"%d",&test[i]); -         } -         intnum,sum; -          for(i=1; i<=n;i++){ -Cin>>P[i].name; inp[i].sum=0; -scanf"%d",&sum); to              for(j=1; j<=sum;j++){ +scanf"%d",&num); -p[i].sum+=Test[num]; the             } *         } $          for(i=1; i<=n;i++) {//bubblingPanax Notoginseng              for(j=i+1; j<=n;j++) {//the small or the name ascending -                 if((p[i].sum<p[j].sum) | | (P[I].SUM==P[J].SUM&AMP;&AMP;STRCMP (P[i].name,p[j].name) >0)){ thePeople pp=P[j]; +p[j]=P[i]; Ap[i]=pp; the                 } +             } -         } $num=0; $          for(i=1; i<=n;i++){ -             if(p[i].sum>=g) { -num++; the             } -             Else{Wuyi                  Break; the             } -         } Wucout<<num<<Endl; -          for(i=1; i<=num;i++){ Aboutcout<<p[i].name<<" "<<p[i].sum<<Endl; $         } -     } -     return 0; -}

Nine degrees OJ topic 1014: Ranking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.