New Ket Little Pale Moon sheds 3 I Rank "structure sort/more complex/detail"

Source: Internet
Author: User

Link: https://Www.nowcoder.com/acm/contest/87/ISource: The CWBC and Xhrlyb have taken part in the SDOI2018, and they are particularly concerned about their rankings. We define the criteria for each player in each match to be divided into its score multiplied by the full mark and divided by the highest score scored by the player in the match . NOIP2017 is divided into 600 points, SDOI2018 each day of the game full score is 300 points. We define a standard score of NOIP2017.%, plus SDOI2018 two days before the standard cent of the sum of 25%, plus SDOI2018 two days after the standard points of the sum of 50%. Xhrlyb tells you the score of each player in each race, and you need to output their names and totals according to the rank from highest to lowest. Smart you will be able to solve this problem smoothly after reading the topic carefully! Input Description: The input data has multiple sets of data, for each group of data, the format is: the first row, an integer n, indicating the number of players. The next n rows, each line is a string of characters separated by a space and five integers, respectively, indicating the player's name, NOIP2017 score and SDOI2018 four-day match. Output Description: There should be more than one set of output data, each set of output has multiple lines, each line should have a contestant name and his total score. The total score of the output should be 5 decimal places, and if the total error does not exceed ten-5, we think two contestants are tied up. If the two contestants are tied, the dictionary order of names is output from small to large. Example 1 input7tzt570 290 155  - 295TYC570 260 225 295  -rqy540 275  the 290 290CZ520 260  the 285 290hly490 185 155 290 285Zhx510  -  the 285 285DZM510 185  - 280 280output TYC589.74138tzt574.16667rqy539.89262CZ534.91682hly515.95886Zhx512.77374DZM490.38869Note: Ensure that the names are in lowercase letters and the number is in the [2,Ten], the score of each match will not exceed the full mark and will not be less than 0 points. Guarantee that the total number of contestants will not exceed 2 ∗ the. 1≤t≤5。

"Analysis": Attention is the highest score the player has won in the competition! Portrait comparison!

"Code":

#include <bits/stdc++.h>/*7tzt 570 290 155 295TYC 570 260 225 295 300rqy 540 275 290 290cz 520 260 285 290hly 490 185 155 290 285zhx 510 285 285DZM 510 185 280 280*/using namespacestd;#definell Long Long#defineull unsigned long Long#defineMoD 1000000007#defineINF 0x3f3f3f3fConst intN =2*1e5+5;structnode{stringname; ints[5]; Doublesum;} A[n];BOOLCMP (Node A, Node B) {//If the total error does not exceed 10-5, we think the two contestants are tied//two contestants side by side, then the name of the dictionary sequence from small to large output    if(Fabs (a.sum-b.sum) <=1e-5)returna.name<B.name; Else        returnA.sum>b.sum;}intMain () {intN;  while(cin>>N) {intmax[ -]; memset (Max,-1,sizeofMax);  for(intI=0; i<n;i++) A[i].sum=0;  for(intI=0; i<n;i++) {cin>>A[i].name;  for(intj=0;j<5; j + +) {cin>>A[i].s[j]; MAX[J]=Max (max[j],a[i].s[j]); }        }         for(intI=0; i<n;i++)        {             for(intj=0; j<5; J + +)            {                if(j==0) {a[i].sum+ = (a[i].s[0]*600.0/max[0])*0.25; }                if(j>0&&j<=2) {a[i].sum+ = (a[i].s[j]*300.0/MAX[J]) *0.25; }                if(j>2&&j<5) {a[i].sum+ = (a[i].s[j]*300.0/MAX[J]) *0.5; }}} sort (A,a+n,cmp);  for(intI=0; i<n;i++) {cout<<A[i].name; printf ("%.5f\n", a[i].sum); }    }}

#include <bits/stdc++.h>/*7tzt 570 290 155 295TYC 570 260 225 295 300rqy 540 275 290 290cz 520 260 130 285 29  0hly 185 155 290 285zhx 510 490 285 285dzm 510 185 280 280*/using namespace std; #define LL Long Long#define ull    unsigned long long#define mod 1000000007#define inf 0x3f3f3f3fconst int N = 2*1e5+5;struct node{string name;    int s[5]; Double sum;} A[n];bool CMP (Node A, node B) {//If the total error does not exceed 10-5, we believe that two players are tied to//two players, then the dictionary order of the names from small to large output if (Fabs (a.sum-b.sum) <=1e    -5) return a.name<b.name; else return a.sum>b.sum;}    int main () {int n;        while (cin>>n) {int max[50];        memset (max,-1,sizeof Max);         for (int i=0;i<n;i++) a[i].sum=0;            for (int i=0;i<n;i++) {cin>>a[i].name;                for (int j=0;j<5;j++) {cin>>a[i].s[j];            Max[j]=max (Max[j],a[i].s[j]);        }} for (int i=0;i<n;i++){A[i].sum + = A[i].s[0]*600/(double) max[0]*0.25;            for (int j=1;j<3;j++) A[i].sum + = A[i].s[j]*300/(double) max[j]*0.25;         for (int j=3;j<5;j++) A[i].sum + = A[i].s[j]*300/(double) max[j]*0.5;         } sort (a,a+n,cmp);            for (int i=0;i<n;i++) {cout<<a[i].name;        printf ("%.5f\n", a[i].sum); }    }}

  

 

New Ket Little Pale Moon sheds 3 I Rank "structure sort/more complex/detail"

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.