Olympic ranking problems score: 2

Source: Internet
Author: User

time limit:1 seconds Memory Limit:32 MB Special Questions:Whether Submit:62 Solution:31 tags
    • Sort
Title Description

According to the requirements, to the country ranking.

Input format

There are multiple sets of data.
The first line gives the number of countries N, the number of countries required to rank m, the country number from 0 to N-1.
The second line starts with n rows for the number of Olympic gold medals, medals, and population (million) for a given country or region.
The next line gives the M country number.

Output

There are 4 ways of sorting: Gold medal total Medal total medal population Proportion medal population proportion
Best ranking and final rankings for each country
Format: rank: Rank Way
If you have the same final rank, the ranking is the lowest ranking, for the ranking method, total gold medal < medal total < gold population ratio < medal population ratio
If there is a parallel ranking, that is, if the total number of gold medals is 100,90,90,80. The ranking is 1,2,2,4.
Add a blank line after each set of data.

Sample input

4 4
4 8 1
6 6 2
4 8 2
2 12 4
0 1 2 3
4 2
8 10 1
8 11 2
8 12 3
8 13 4
0 3

Sample output

1:3
1:1
2:1
1:2

1:1

1:1



1 //at nine degrees WA, but other Ojac2 3  4#include <iostream>5#include <algorithm>6 using namespacestd;7 structE8 {9     intnum,golde,model,people;Ten intoder[4]; One}buf[100000]; A   - BOOLcmp0 (E a,e b) - { the returna.num<B.num; - } -   - BOOLCmp1 (E a,e b) + { - returnA.golde>B.golde; + } A   at BOOLCMP2 (E a,e b) - { - returnA.model>B.model; - } -   - BOOLCmp3 (E a,e b) in { - return(a.golde/a.people) > (b.golde/b.people); to } +   - BOOLCmp4 (E a,e b) the { * return(a.model/a.people) > (b.model/b.people); $ }Panax Notoginseng   - intMain () the { +    intn,m; A     while(cin>>n>>M) the    { +        for(intI=0; i<n;i++) -  { $buf[i].num=i; $Cin>>buf[i].golde>>buf[i].model>>buf[i].people; -  } -   for(intI=0; i<m;i++) the  { -    inttemp;WuyiCin>>temp; thebuf[i]=Buf[temp]; -  } Wu         -Sort (BUF,BUF+M,CMP1);//1 About   for(intI=0; i<m;i++) $  { -  if(i!=0&&buf[i-1].golde==Buf[i].golde) -buf[i].oder[0]=buf[i-1].oder[0]; -  Else Abuf[i].oder[0]=i+1; +   the  } -   $   theSort (BUF,BUF+M,CMP2);//2 the   for(intI=0; i<m;i++) the  { the  if(i!=0&&buf[i-1].model==Buf[i].model) -buf[i].oder[1]=buf[i-1].oder[1]; in  Else thebuf[i].oder[1]=i+1; the   About  } the   the   theSort (Buf,buf+m,cmp3);//3 +   for(intI=0; i<m;i++) -  { the  if(i!=0&& (buf[i-1].golde/buf[i-1].people) = = (buf[i].golde/buf[i].people))Bayibuf[i].oder[2]=buf[i-1].oder[2]; the  Else thebuf[i].oder[2]=i+1; -  } -   the   theSort (buf,buf+m,cmp4);//4 the   for(intI=0; i<m;i++) the  { -  if(i!=0&& (buf[i-1].model/buf[i-1].people) = = (buf[i].model/buf[i].people)) thebuf[i].oder[3]=buf[i-1].oder[3]; the  Else thebuf[i].oder[3]=i+1;94  } the   theSort (buf,buf+m,cmp0); the   for(intI=0; i<m;i++)98  { About  intindex=0; -      for(intj=0;j<4; j + +)101 {102 if(buf[i].oder[j]<Buf[i].oder[index])103index=J;104 } the  106cout<<buf[i].oder[index]<<":"<<index+1<<Endl;107  }108cout<<Endl;109    } the    return 0;111 }   the  

Olympic ranking problems score: 2

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.