码迷,mamicode.com
首页 > 其他好文 > 详细

SDOI(队列)

时间:2015-10-10 21:36:16      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:

SDOI

Accepts: 393
Submissions: 993
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
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 people comes to the Select and there is 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 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 .(it is promised that not all person in one round is 0,in another way,x> ). 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.3round′  final mark + 0.7round′  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 in the first line for the number of testcases and followed T  testcases. For each testcase, there are two integers and in the first line(nm , standing for the number of people take part in SDOI and the allowance of the team.Followed with 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 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

题解:第一次打bc,弱爆了,水了一题,还各种错。。。。这道题没注意还要找最值300/x,错了半天;
代码:
 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<queue>
 4 #include<algorithm>
 5 using namespace std;
 6 #define bj (b.r1*0.3*ch(x)+b.r2*0.7*ch(y))>(a.r1*0.3*ch(x)+a.r2*0.7*ch(y))
 7 #define MAX(x,y)(x>y?x:y)
 8 #define ch(x) (300.0/x)
 9 int T,n,m,x,y;
10 struct Node{
11     char name[25],sex[10];
12     int r1,r2;
13     friend bool operator < (Node a,Node b){
14         if((b.r1*0.3*ch(x)+b.r2*0.7*ch(y))-(a.r1*0.3*ch(x)+a.r2*0.7*ch(y))>0)return 1;
15         else return 0;
16     }
17 };
18 void getx(Node a){
19     x=MAX(x,a.r1);
20     y=MAX(y,a.r2);
21 }
22 int main(){
23     scanf("%d",&T);
24     while(T--){
25         priority_queue<Node>d1,d2;
26         scanf("%d%d",&n,&m);
27         Node a,b;
28         int girl=0;
29         x=y=0;
30         for(int i=0;i<n;i++){
31             scanf("%s%s%d%d",a.name,a.sex,&a.r1,&a.r2);
32             getx(a);
33             if(!strcmp(a.sex,"male"))d1.push(a);
34             else{
35                 d2.push(a);
36                 girl=1;
37             }
38         }
39         int temp=0;
40         puts("The member list of Shandong team is as follows:");
41         for(int i=0;i<m-1;i++){
42             a=d1.top();
43             b=d2.top();
44             if(bj){
45                 temp=1;
46                 d2.pop();
47                 puts(b.name);
48                 //printf("%.2lf\n",b.r1*0.3*ch(x)+b.r2*0.7*ch(y));
49             }
50             else{
51                 d1.pop();
52                 puts(a.name);
53                 //printf("%.2lf\n",a.r1*0.3*ch(x)+a.r2*0.7*ch(y));
54             }
55         }
56         if(!temp&&girl){
57             b=d2.top();
58             puts(b.name);
59         //    printf("%.2lf\n",b.r1*0.3*ch(x)+b.r2*0.7*ch(y));
60         }
61         else{
62             a=d1.top();
63             puts(a.name);
64         //    printf("%.2lf\n",a.r1*0.3*ch(x)+a.r2*0.7*ch(y));
65         }
66     }
67     return 0;
68 }

 

SDOI(队列)

标签:

原文地址:http://www.cnblogs.com/handsomecui/p/4868304.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!