Justoj 2039: Ranking of grades (structure sort)

Source: Internet
Author: User
Tags gcd

Title Description

Each time the final exam results come out of a period of time before the Big Brother in the heart is painful, always feel that they will be in the class particularly poor. So when the results come out Big brother want to quickly know the general ranking in class, in order to know their rankings. (PS: Dahao Brother class has a genius called Day, aka Teddy, Don't ask me why, because Teddy's behavior decided)

Input

Multiple sets of test data to the end of the file.
First enter each class has n students, this semester has M Gate Course (1<=n,m<=100)
Next there are n lines, each line of input format is the number ID, name name, course score K1, course score K2 ..., course score km. (The number is within the range of int, 0<=ki<=100, the name is less than 20 characters long)

Output

Output class Each student rank, and output total score and rank (if the total score is the same as the number from small to large output, but the ranking is the same) output format see sample

Sample input
4 Taidi 902 Dahaoge 603 yeshen 50 60 100 80 (1004 Wangpangzi)
Sample output
1 Taidi sum = 380 Ranking = yeshen, sum = 380 Ranking = wangpangzi, sum = 290. Ranking = dahaoge, Sum = Ranking = 4

PUZZLE: Structure sequencing
1#include <iostream>2#include <algorithm>3#include <cstring>4#include <cstdio>5#include <vector>6#include <cstdlib>7#include <iomanip>8#include <cmath>9#include <ctime>Ten#include <map> One#include <Set> A#include <queue> - using namespacestd; - #defineLowbit (x) (x& (×)) the #defineMax (x, y) (x>y?x:y) - #defineMin (x, y) (x<y?x:y) - #defineMAX 100000000000000000 - #defineMOD 1000000007 + #definePi ACOs (-1.0) - #defineEI exp (1) + #definePI 3.141592653589793238462 A #defineINF 0x3f3f3f3f3f at #defineMem (a) (Memset (A,0,sizeof (a))) -typedefLong Longll; - ll gcd (ll A,ll b) { -     returnB?GCD (b,a%b): A; - } - Const intn= the; in Const intmod=1e9+7; - structnode to { +     intID; -     stringname; the     intGrade[n]; *     intsum; $ }stu[n];Panax Notoginseng BOOLCMP (node A,node b) - { the     if(a.sum==b.sum) +         returna.id<b.id; A     returnA.sum>b.sum; the } + intMain () - { $     intN,m,num; $Cin.sync_with_stdio (false); -      while(cin>>n>>L) { -          for(intI=0; i<n;i++){ theCin>>stu[i].id>>Stu[i].name; -stu[i].sum=0;Wuyi              for(intj=0; j<m;j++){ theCin>>Stu[i].grade[j]; -stu[i].sum+=Stu[i].grade[j]; Wu             } -         } AboutSort (stu,stu+n,cmp); $          for(intI=0; i<n;i++){ -cout<<stu[i].id<<" "<<Stu[i].name; -              for(intj=0; j<m;j++){ -cout<<" "<<Stu[i].grade[j]; A             } +             if(i==0) num=1; the             Else if(stu[i].sum!=stu[i-1].sum) -num=i+1; $cout<<"Sum ="<<stu[i].sum<<"Ranking ="<<num<<Endl; the         } the     } the     return 0; the}

Justoj 2039: Ranking of grades (structure sort)

Related Article

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.