SDOI

来源:互联网 发布:优雅的淘宝收件人名字 编辑:程序博客网 时间:2024/06/16 04:44

The Annual National Olympic of Information(NOI) will be held.The province of Shandong hold a Select(which we call SDOI for short) to choose some people to go to the NOI.n(n100)n(n100) people comes to the Select and there is m(m50)m(m50) people who can go to the NOI.

According to the tradition and regulation.There were two rounds of the SDOI, they are so called "Round 1" and "Round 2", the full marks of each round is
300300.

All the n people take part in Round1 and Round2, now the original mark of every person is known. The rule of SDOI of ranking gets to the "standard mark". For each round there is a highest original mark,let's assume that is
xx.(it is promised that not all person in one round is 0,in another way,x>0x>0). So for this round,everyone's final mark equals to his/her original mark(300/x)mark(300/x).

After we got everyone's final mark in both round.We calculate the Ultimate mark of everyone as
0.3round1s0.3round1s final mark + 0.7round2s0.7round2s final mark.It is so great that there were no two persons who have the same Ultimate mark.

After we got everyone's Ultimate mark.We choose the persons as followed:

To encourage girls to take part in the Olympic of Information.In each province,there has to be a girl in its teams.

1. If there is no girls take part in SDOI,The boys with the rank of first m enter the team.
2. If there is girls, then the girl who had the highest score(compared with other girls) enter the team,and other(boys and other girls) m-1 people with the highest mark enter the team.

Just now all the examination had been finished.Please write a program, according to the input information of every people(Name, Sex ,The original mark of Round1 and Round2),Output the List of who can enter the team with their Ultimate mark decreasing.

Input
There is an integer T(T100)T(T100) in the first line for the number of testcases and followed TT testcases.

For each testcase, there are two integers
nn and mm in the first line(nm)(nm), standing for the number of people take part in SDOI and the allowance of the team.Followed withnn lines,each line is an information of a person. Name(A string with length less than2020,only contain numbers and English letters),Sex(male or female),the Original mark of Round1 and Round2 (both equal to or less than300300) separated with a space.

Output
For each testcase, output "The member list of Shandong team is as follows:" without Quotation marks.

Followed
mm lines,every line is the name of the team with their Ultimate mark decreasing.
Sample Input
210 8dxy male 230 225davidwang male 218 235evensgn male 150 175tpkuangmo female 34 21guncuye male 5 15faebdc male 245 250lavender female 220 216qmqmqm male 250 245davidlee male 240 160dxymeizi female 205 1902 1dxy male 300 300dxymeizi female 0 0
Sample Output
The member list of Shandong team is as follows:faebdcqmqmqmdavidwangdxylavenderdxymeizidavidleeevensgnThe member list of Shandong team is as follows:dxymeiziHintFor the first testcase: the highest mark of Round1 if 250,so every one's mark times(300/250)=1.2, it's same to Round2.The Final of The Ultimate score is as followedfaebdc 298.20qmqmqm 295.80davidwang 275.88dxy 271.80lavender 260.64dxymeizi 233.40davidlee 220.80evensgn 201.00tpkuangmo 29.88guncuye 14.40For the second testcase,There is a girl and the girl with the highest m

题目大意:(zz博主翻译不好。。。)

问题描述
一年一度的全国信息学奥林匹克竞赛(NOI)即将举办,SD省组织进行了一次省队选拔,一共有 n (n \leq 100)n(n100)名选手参加了这次省队选拔。今年,SD省的省队名额为 m (m \leq 50)m(m50) 人,即,今年的SD省队有 mm 名队员。按照惯例,SD省的省队选拔有两轮比赛,依次为“Round1”和“Round2”,每个Round的满分为 300300 分。所有 n 名选手都参加了Round1和Round2,现在每名选手Round1和Round2的“原始得分”已经确定。SD省的省队选拔采用标准分计算方式,即,设某个Round的最高原始得分为 xx 分(保证每轮比赛都不会全场零分,即x>0x>0),那么此Round每名选手的“相对得分”为: 这名选手此Round的原始得分* (300 / x)(300/x)。所有选手的Round1和Round2的相对得分计算完毕后,将计算每名选手的“最终成绩”。一名选手的最终成绩为:这名选手的Round1相对得分* 0.30.3 + 这名选手的Round2相对得分* 0.70.7。非常和谐的是,保证不存在两名选手的最终成绩相等。所有选手的最终成绩计算完毕后,将会按照以下规则选出省队队员:为了鼓励女生参加信息学奥赛及相关活动,在有女选手参加省队选拔的情况下,省队中有一个固定的女选手名额。1)若没有女选手参加省队选拔,则最终成绩最高的 mm 位选手进入省队。2)若有女选手参加省队选拔,则最佳女选手(女选手中最终成绩最高者)进入省队,其余的选手(男选手和最佳女选手之外的女选手)中成绩最高的 m-1m1 位选手进入省队。现在已经到了省队选拔的最后阶段,请你编写一个程序,根据输入的所有选手的信息(姓名,性别,Round1和Round2的原始得分),输出进入省队的选手的姓名,输出的姓名按照省队队员的最终成绩降序(从高到低)排列。

思路:(计分方式多观察)
女生是个解题的关键,没有女生sort+结构体直接输出就行;
有女生输出最大的那个,并且其是否在前m中;
在,直接排序;不在,把第m个男生换成女生;

#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;struct node {char a[100];char b[100];double c;double d;double e;}s[1010];bool cmp(node x,node y){return x.e>y.e;}int main(){int m,n,i,j,t;scanf("%d",&t);while(t--){j=0;bool ans=true;double max1=0.0,max2=0.0,max3=0.0;scanf("%d %d",&n,&m);for(i=0;i<n;i++){scanf("%s %s %lf %lf",s[i].a,s[i].b,&s[i].c,&s[i].d);if(!strcmp(s[i].b,"female"))ans=false;if(max1<s[i].c)max1=s[i].c;if(max2<s[i].d)max2=s[i].d;}for(i=0;i<n;i++){s[i].e=0.3*s[i].c*(300.0/max1)+0.7*s[i].d*(300.0/max2);if(!strcmp(s[i].b,"female")){if(s[i].e>max3){max3=s[i].e;}}}sort(s,s+n,cmp);printf("The member list of Shandong team is as follows:\n");if(ans){for(i=0;i<m;i++)    {    printf("%s\n",s[i].a);    }}else{for(i=0;i<n;i++){if(s[i].e==max3)j=i;}if(max3>=s[m-1].e && !ans){for(i=0;i<m;i++){printf("%s\n",s[i].a);}}else {for(i=0;i<m-1;i++){printf("%s\n",s[i].a);}printf("%s\n",s[j].a);}}}return 0;}


0 0
原创粉丝点击