HDU/5499/模拟
题目链接
模拟题,直接看代码。
£:分数的计算方法,要用double;
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> pa;
typedef long long LL;
const int maxn=100+100;
struct node
{
string na;
double a;
double b;
double ans;
bool operator<(const node x)const
{
return x.ans<ans;
}
};
node man [maxn];
node woman[maxn];
node t [maxn];
string x1,x2;
double t1=0.0,t2=0.0;
void init()
{
for(int i=0;i<=100+1;i++)
{
woman[i].ans=0;
man [i].ans=0;
t [i].ans=0;
}
}
int main ()
{
int T;
scanf("%d",&T);
while(T--)
{
init();
int n,m;
scanf("%d%d",&n,&m);
int k1=0,k2=0;
bool fg=0;
double xx=0.0,yy=0.0;
for(int i=0;i<n;i++)
{
cin>>x1>>x2>>t1>>t2;
if(x2[0]=='m')
{
man[k1].na=x1;
man[k1].a=t1;
man[k1].b=t2;
xx=max(xx,t1);
yy=max(yy,t2);
k1++;
}
else
{
fg=1;
woman[k2].na=x1;
woman[k2].a=t1;
woman[k2].b=t2;
xx=max(xx,t1);
yy=max(yy,t2);
k2++;
}
}
xx=(double)300.0/(double)xx;
yy=(double)300.0/(double)yy;
for(int i=0;i<k1;i++)
man[i].ans=(double)man[i].a*xx*0.3+man[i].b*yy*0.7;
for(int i=0;i<k2;i++)
woman[i].ans=(double)woman[i].a*xx*0.3+woman[i].b*yy*0.7;
sort(woman,woman+k2);
if(fg)
{
int k=0;
t[k].na=woman[0].na;
t[k].ans=woman[0].ans;
k++;
for(int i=1;i<k2;i++)
{
man[k1].na=woman[i].na;
man[k1].ans=woman[i].ans;
k1++;
}
sort(man,man+k1);
for(int i=0;i<m-1;i++)
{
t[k].na=man[i].na;
t[k].ans=man[i].ans;
k++;
}
sort(t,t+m);
cout<<"The member list of Shandong team is as follows:"<<endl;
for(int i=0;i<m;i++)
cout<<t[i].na<<endl;
}
else
{
for(int i=0;i<k2;i++)
{
man[k1].na=woman[i].na;
man[k1].ans=woman[i].ans;
k1++;
}
sort(man,man+k1);
cout<<"The member list of Shandong team is as follows:"<<endl;
for(int i=0;i<m;i++)
cout<<man[i].na<<endl;
}
}
return 0;
}
想的太多,做的太少。