原题

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(n≤100) people comes to the Select and there is m(m≤50) 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 300.

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 x.(it is promised that not all person in one round is 0,in another way,x>0). So for this round,everyone's final mark equals to his/her original mark∗(300/x).

After we got everyone's final mark in both round.We calculate the Ultimate mark of everyone as 0.3∗round1′s final mark + 0.7∗round2′s

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(T≤100) in the first line for the number of testcases and followed T testcases.

For each testcase, there are two integers n and m in the first line(n≥m), standing for the number of people take part in SDOI and the allowance of the team.Followed with n lines,each line is an information of a person. Name(A string with length less than 20,only contain numbers and English letters),Sex(male or female),the Original mark of Round1 and Round2 (both equal to or less than 300

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

Followed m

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:
dxymeiziHint
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.40For 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.

代码:

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct peo{
    string name;
    string sex;
    int r1;
    int r2;
    double com;
}a[105];

bool cmp(peo x,peo y)
{
    return y.com<x.com ;
}

//double com[105];
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int sum,ok;
        cin>>sum>>ok;
        double r1max=0,r2max=0,femax=0;
        double beir1,beir2;
        string nvmax="0";
        for(int i=0;i<sum;i++)
        {
            cin>>a[i].name >>a[i].sex>>a[i].r1>>a[i].r2;
            if(r1max<a[i].r1) r1max=a[i].r1;
            if(r2max<a[i].r2) r2max=a[i].r2;
        }
        beir1=300/r1max;
        beir2=300/r2max;
        for(int i=0;i<sum;i++)
        {
            a[i].com=a[i].r1*0.3*beir1+a[i].r2*0.7*beir2;
            if(a[i].sex=="female")
            {
        //        cout<<"1";
                if(a[i].com>=femax)
                {
        //            cout<<"2";
                    femax=a[i].com;//femax是女生最高总分
                    nvmax=a[i].name;//nvmax是女生名字
                }
                
            }
            
        }
        sort(a,a+sum,cmp);
        if(nvmax=="0")
        {
            cout<<"The member list of Shandong team is as follows:"<<endl;
            for(int i=0;i<ok;i++)    
                cout<<a[i].name<<endl;
        //        cout<<"1";
                }
        else
        {
            if(a[ok-1].com<femax)
            {
                cout<<"The member list of Shandong team is as follows:"<<endl;
                for(int i=0;i<ok;i++)    
                    cout<<a[i].name<<endl;
        //            cout<<"2";
            }
                
            else
            {
                cout<<"The member list of Shandong team is as follows:"<<endl;
                for(int i=0;i<ok-1;i++)    
                cout<<a[i].name<<endl;
                cout<<nvmax<<endl;
        //        cout<<"3";
                
            }
         }
    
        
    }
 }

寒假训练1—H(第一次写出结构体数组)相关推荐

  1. 修改程序配置文件 以及写一个结构体数组到文件(以及整数和结构体)

    1.修改配置文件  这个mycp 是上一节的  这是TEST.config 代码需用到strstr 这个就是代码 结果这么写不对,缺点东西 改正完的结果是什么呢 ? 这个必须得打开文件  可不可以在外 ...

  2. 写出结构优雅代码的4个技巧

    写出结构优雅代码就像成为武林高手一样,需要积累思考勤学苦练.冰冻三尺非一日之寒.成熟的业界套路肯定是没有的,因为代码也有思想流派.现在是百家齐放的时代.code review时,一个不留神就会吵起来. ...

  3. linux文件编程(3)—— main函数传参、myCp(配置成环境变量)、修改配置文件、整数和结构体数组写到文件

    参考:linux文件编程(3)-- 文件编程的简单应用:myCp.修改配置文件 作者:丶PURSUING 发布时间: 2021-04-09 23:45:05 网址:https://blog.csdn. ...

  4. C语言编程题—结构体—设计程序,已知学生的记录由学号和学习成绩构成,N名学生的数据已存入a结构体数组中。请编写函数 fun:找出成绩最低的学生记录,通过形参返回主函数(规定只有一个最低分

    4 C语言编程题--结构体 **设计程序,已知学生的记录由学号和学习成绩构成,N名学生的数据已存入a结构体数组中.请编写函数 fun,函数的功能是:找出成绩最低的学生记录,通过形参返回主函数(规定只有 ...

  5. C语言编程>第十二周 ③ 已知学生的记录由学号和学习成绩构成,M名学生的数据已存入a结构体数组中。请编写函数fun,该函数的功能是:找出成绩最高的学生记录,通过形参返回主函数。

    已知学生的记录由学号和学习成绩构成,M名学生的数据已存入a结构体数组中.请编写函数fun,该函数的功能是:找出成绩最高的学生记录,通过形参返回主函数(规定只有一个最高分).已给出函数的首部,请完成该函 ...

  6. c语言通讯录链表结构体排序,写个通讯录 想要简单就全用的是结构体数组要求改成用链表的...专业的朋友看能不能最简洁的改一下...

    已结贴√ 问题点数:20 回复次数:10 写个通讯录 想要简单就全用的是结构体数组要求改成用链表的...专业的朋友看能不能最简洁的改一下 写个通讯录 想要简单就全用的是结构体数组...不符合要求 要改 ...

  7. 算法训练 - P1101 ——有一份提货单,其数据项目有:商品名(MC)、单价(DJ)、数量(SL)。定义一个结构体prut,其成员是上面的三项数据。在主函数中定义一个prut类型的结构体数组,输入每

    问题描述 有一份提货单,其数据项目有:商品名(MC).单价(DJ).数量(SL).定义一个结构体prut,其成员是上面的三项数据.在主函数中定义一个prut类型的结构体数组,输入每个元素的值,计算并输 ...

  8. C语言试题五十一之已知学生的记录是由学号和学习成绩构成,n名学生的数据已存入s结构体数组中。请编写函数fun,该函数的功能是:找出成绩最高的学生记录,通过形参返回主函数(规定只有一个最高分)。

    1. 题目 请编写一个函数void function(Student a[], int n, Student *s),其功能时:已知学生的记录是由学号和学习成绩构成,n名学生的数据已存入s结构体数组中 ...

  9. 创建结构体数组保存5名学生的成绩单(每人包含3门课程成绩),计算每人成绩的总分,并打印出总分的最高分...

    在 C 语言中,可以使用如下的代码来创建结构体数组并保存学生的成绩单: #define N 5 #define M 3struct student {int id;char name[20];int ...

  10. 【C 语言】文件操作 ( 读取文件中的结构体数组 | feof 函数使用注意事项 )

    文章目录 一.读取文件中的结构体数组 | feof 函数使用注意事项 二.代码示例 一.读取文件中的结构体数组 | feof 函数使用注意事项 读取文件结构体时 , 可以循环读取文件中的数据 , 只使 ...

最新文章

  1. 北师大毕彦超:AI和人类感知的相同点和不同点
  2. java web 笔试 题_JavaWeb综合笔试题(带答案).doc
  3. 洛谷P1527 [国家集训队] 矩阵乘法 [整体二分,二维树状数组]
  4. Mac OS使用技巧之八:Dock栏使用技巧
  5. Python(24)-面向对象3-可迭代类对象Pokemon
  6. JDK源码解析之 java.lang.Class
  7. 计算机键盘大赛活动总结,参加技能大赛的活动总结
  8. Spring-AnnotatedBeanDefinitionReader
  9. Webpack webpack+gulp实现自动构建部署
  10. Cool edit pro 2.1简体中文版下载
  11. log4j 日志书写格式_Log4J日志配置详解
  12. 极路由php插件开发,极路由3刷机过程
  13. 小技巧 - 如何下载微信公众号音频?(附:此方法可用于类似的Web)
  14. lbj学习日记 03 循环和选择结构的刷题心得
  15. 重庆声光电安全预警平台项目启动会顺利召开
  16. java银行项目对于金额的面试题,华为java面试视频直播
  17. input只能输入数字0-9(不含小数点)
  18. 每晚泡脚15分钟,5年下来有哪些变化
  19. cxonev4验证用户_cxone软件配置
  20. 基于Android的手机安全卫士的开发

热门文章

  1. 手机计算机里面的符号代表什么意思,计算器上的符号各代表什么意思?
  2. php 检测链接,PHP检测链接是否存在的代码实例分享
  3. ADO.NET如何读取Excel(转自晓风残月)
  4. 手机浏览器获取某东cookie
  5. 域名投毒,DNS污染,域名欺骗,其实就是域名污染。
  6. 重庆云阳2021云中高考成绩查询,重庆云阳中学2021年招生简章
  7. 苹果CEO库克的逆袭之路
  8. 数据库原理-并发控制(2-封锁)
  9. 聊聊DevOps制品管理-不止是存储制品这么简单
  10. OS系列——操作系统镜像加载BIOS固件工作原理详解