题目来源:点击打开链接
Recently, the ACM/ICPC team of Marjar University decided to choose some new members from freshmen to take part in the ACM/ICPC competitions of the next season. As a traditional elite university in ACM/ICPC, there is no doubt that application forms will fill up the mailbox. To constitute some powerful teams, coaches of the ACM/ICPC team decided to use a system to score all applicants, the rules are described as below. Please note that the score of an applicant is measured by pts, which is short for "points".
1. Of course, the number of solved ACM/ICPC problems of a applicant is important. Proudly, Marjar University have a best online judge system called Marjar Online Judge System V2.0, and in short, MOJ. All solved problems in MOJ of a applicant will be scored under these rules:
2. Competitions also show the strength of an applicant. Marjar University holds the ACM/ICPC competition of whole school once a year. To get some pts from the competition, an applicant should fulfill rules as below:
3. We all know that some websites held problem solving contest regularly, such as JapanJam, ZacaiForces and so on. The registered member of JapanJam will have a rating after each contest held by it. Coaches thinks that the third highest rating in JapanJam of an applicant is good to show his/her ability, so the scoring formula is:
Here r is the third highest rating in JapanJam of an applicant.
4. And most importantly - if the applicant is a girl, then the score will be added by 33 pts.
The system is so complicated that it becomes a huge problem for coaches when calculating the score of all applicants. Please help coaches to choose the best M applicants!
There are multiple test cases.
The first line of input is an integer T (1 ≤ T ≤ 10), indicating the number of test cases.
For each test case, first line contains two integers N (1 ≤ N ≤ 500) - the number of applicants and M (1 ≤ M ≤ N) - the number of members coaches want to choose.
The following line contains an integer R followed by R (0 ≤ R ≤ 500) numbers, indicating the id of R problems in MaoMao Selection.
And then the following line contains an integer S (0 ≤ S ≤ 500) followed by S numbers, indicating the id of S problems from Old Surgeon Contest.
The following line contains an integer Q (0 ≤ Q ≤ 500) - There are Q teams took part in Marjar University's competition.
Following Q lines, each line contains a string - team name and one integer - prize the team get. More specifically, 1 means first prize, 2 means second prize, 3 means third prize, and 0 means no prize.
In the end of each test case, there are N parts. In each part, first line contains two strings - the applicant's name and his/her team name in Marjar University's competition, a char sex - M for male, F for female and two integers P (0 ≤ P ≤ 1000) - the number of problem the applicant solved, C (0 ≤ C ≤ 1000) - the number of competitions the applicant have taken part in JapanJam.
The following line contains P integers, indicating the id of the solved problems of this applicant.
And, the following line contains C integers, means the rating for C competitions the applicant have taken part in.
We promise:
For each test case, output M lines, means that M applicants and their scores. Please output these informations by sorting scores in descending order. If two applicants have the same rating, then sort their names in alphabet order. The score should be rounded to 3 decimal points.
1 5 3 3 1001 1002 1003 4 1004 1005 1006 1007 3 MagicGirl!!! 3 Sister's_noise 2 NexusHD+NexusHD 1 Edward EKaDiYaKanWen M 5 3 1001 1003 1005 1007 1009 1800 1800 1800 FScarlet MagicGirl!!! F 3 5 1004 1005 1007 1300 1400 1500 1600 1700 A NexusHD+NexusHD M 0 0 B None F 0 0 IamMM Sister's_noise M 15 1 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 3000
FScarlet 60.000 IamMM 44.300 A 36.000
很长的一个模拟题,但是思路清楚的话毫无难度,要求分析几个学生的ACM程序设计总分,总分分为以下几块。
1、平常做题的题号,分为四类:MaoMao Selection,Old Surgeon Contest ,题号为质数的问题,一般问题,有不同的权值。这几项没有冲突。
2、校赛排名加分,给出队伍名和名次。
3、japanjam的加权分数,要求是第三高的分数,找到第三高的分数代入公式。
4、女生加33分。
其实就是四个小问题。。。。合起来就是了。
#include <iostream> #include <map> #include <cstring> #include <string> #include <cmath> #include <iomanip> #include <algorithm> using namespace std; int maomaoselection[505]; int olddot[505]; int maomaonum,oldnum; int cflevel[1050]; class competition { public: string team; int ranker; }; class people { public: string name; string team; char sex; double score; }; competition teamer[505]; people mass[505]; bool cmpcf(int a,int b) { return a>b; } double Max(double a,double b) { if(a>b) return a; else return b; } int isprime(int n) { for (int i=2;i<=sqrt(n);i++) { if (n%i==0) return 0; } return 1; } double jamcal(int r) { return Max(0,((r-1200)/100.0)*1.5); } bool ismaomao(int id) { for(int i=0;i<maomaonum;i++) { if(id==maomaoselection[i]) return 1; } return 0; } bool isolddot(int id) { for(int i=0;i<oldnum;i++) { if(id==olddot[i]) return 1; } return 0; } bool cmp(people a,people b) { return a.score>b.score; } int main() { int testcase; cin>>testcase; while(testcase--) { int totalperson,rankperson,tmp,jamaverage; string tmp2; memset(maomaoselection,0,sizeof(maomaoselection)); memset(olddot,0,sizeof(olddot)); map<string,int> team; int competitionnum; cin>>totalperson>>rankperson>>maomaonum; for(int i=0;i<maomaonum;i++) { cin>>maomaoselection[i]; } cin>>oldnum; for(int j=0;j<oldnum;j++) { cin>>olddot[j]; } cin>>competitionnum; for(int i=0;i<competitionnum;i++) { cin>>teamer[i].team>>teamer[i].ranker; } for(int i=0;i<totalperson;i++) { memset(cflevel,0,sizeof(cflevel)); string teamname; int avgscore,solvequestion,cfnum; double res=0; cin>>mass[i].name>>teamname>>mass[i].sex>>solvequestion>>cfnum; mass[i].team=teamname; //第四条加成,女生+33 if(mass[i].sex=='F') res+=33; //第一条加成:平时做题 for(int k=0;k<solvequestion;k++) { cin>>tmp; if(ismaomao(tmp)==1) { res+=2.5; } else if(isolddot(tmp)==1) { res+=1.5; } else if(isprime(tmp)==1) { res+=1; } else { res+=0.3; } } //第二条加成:队伍排名 for(int t=0;t<competitionnum;t++) { if(teamname==teamer[t].team) { if(teamer[t].ranker==1) { res+=36; } else if(teamer[t].ranker==2) { res+=27; } else if(teamer[t].ranker==3) { res+=18; } } } //第三条加成,Jam权重 for(int p=0;p<cfnum;p++) { cin>>cflevel[p]; } sort(cflevel,cflevel+cfnum,cmpcf); avgscore=cflevel[2]; //cout<<"排名第三的是:"<<avgscore<<endl; res+=jamcal(avgscore); mass[i].score=res; //cout<<"结果是"<<mass[i].name<<" "<<mass[i].score<<endl; } sort(mass,mass+totalperson,cmp); for(int a=0;a<rankperson;a++) { cout<<mass[a].name<<" "<<setiosflags(ios::fixed)<<setprecision(3)<<mass[a].score<<endl; } } return 0; }