HDUoj 5499 SDOI (贪心

SDOI

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1105    Accepted Submission(s): 440


Problem Description
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) lines,every line is the name of the team with their Ultimate mark decreasing.
 

Sample Input
  
  
2
10 8
dxy male 230 225
davidwang male 218 235
evensgn male 150 175
tpkuangmo female 34 21
guncuye male 5 15
faebdc male 245 250
lavender female 220 216
qmqmqm male 250 245
davidlee male 240 160
dxymeizi female 205 190
2 1
dxy male 300 300
dxymeizi female 0 0
 

Sample Output
  
  
The member list of Shandong team is as follows:
faebdc
qmqmqm
davidwang
dxy
lavender
dxymeizi
davidlee
evensgn
The member list of Shandong team is as follows:
dxymeizi

Hint
For 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 followed
faebdc 298.20
qmqmqm 295.80
davidwang 275.88
dxy 271.80
lavender 260.64
dxymeizi 233.40
davidlee 220.80
evensgn 201.00
tpkuangmo 29.88
guncuye 14.40

For the second testcase,There is a girl and the girl with the highest mark dxymeizi enter the team, dxy who with the highest mark,poorly,can not enter the team.

 

Source
BestCoder Round #59 (div.2)
题很水注意下 <男女选手的关系就好

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct ST{
    char name[25];
    char sex[15];
    double r,r1,r2;
}p[1000];
int cmp(ST x,ST y)
{
    return x.r > y.r;
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--){
        int n, m, flag = 0, k = 0;
        double max_r1 = 0, max_r2 = 0;
        scanf("%d%d",&n,&m);
        for(int i = 0;i < n; i++){
            scanf("%s %s %lf%lf",p[i].name,p[i].sex,&p[i].r1,&p[i].r2);
            max_r1 = max(max_r1,p[i].r1);
            max_r2 = max(max_r2,p[i].r2);
            if(p[i].sex[0] == 'f'){
                flag = 1;
            }

        }
        for(int i = 0;i < n; i++){
            p[i].r = 300/max_r1*p[i].r1*0.3 + 300/max_r2*p[i].r2*0.7;
        }
        sort(p,p+n,cmp);
        puts("The member list of Shandong team is as follows:");
            if(!flag)
                for(int i = 0;i < m; i++)
                    printf("%s\n",p[i].name); 
            else{
                k = 1;
                for(int i = 0;i < m-1; i++){
                    printf("%s\n",p[i].name);
                    if(k&&p[i].sex[0] == 'f')
                        k = 0;
                }
            if(k){
                for(int i = m-1;i < n; i++){
                    if(p[i].sex[0] == 'f'){
                        printf("%s\n",p[i].name);
                        break;
                    }
                }
            }
            else
            printf("%s\n",p[m-1].name);
        }   
    }
return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值