大模拟,注意1.5*max(0.0, 1.0*(a[2]-1200)/100)这里,如果是int a[ ] 的不要 /100, 要 *0.01
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <queue>
#include <vector>
#include <math.h>
#include <stack>
#include <map>
#define rtl rt<<1
#define rtr rt<<1|1
typedef long long LL;
using namespace std;
const int MAX = 15000+10;
const double eps = 1e-10;
const double PI = acos(-1.0);
int t, n, m;
double a[MAX];
int numa, numb, numt, score, num1, num2, id;
string teamname, sex;
map<string, int>team;
map<int, double>pro;
struct node
{
string name;
double ans;
}lxt[MAX];
bool su(int x)
{
for(int i = 2; i<x/2; ++i)
if(x%i==0)return 0;
return 1;
}
bool cmp1(double a, double b)
{
return a>b;
}
bool cmp(node a, node b)
{
if(a.ans!=b.ans)return a.ans>b.ans;
return a.name<b.name;
}
int main()
{
scanf("%d", &t);
while(t--)
{
team.clear();
pro.clear();
cin>>n>>m;
cin>>numa;
for(int i = 0; i<numa; ++i)
{
scanf("%d", &id);
pro[id] = 2.5;
}
cin>>numb;
for(int i = 0; i<numb; ++i)
{
scanf("%d", &id);
pro[id] = 1.5;
}
cin>>numt;
for(int i = 0; i<numt; ++i)
{
cin>>teamname>>score;
team[teamname] = score;
}
for(int i = 0; i<n; ++i)
{
lxt[i].ans = 0.0;
cin>>lxt[i].name>>teamname>>sex>>num1>>num2;
for(int j = 0; j<num1; ++j)
{
scanf("%d", &id);
if(pro[id])lxt[i].ans+=pro[id];
else if(su(id))lxt[i].ans+=1.0;
else lxt[i].ans+=0.3;
}//printf(" %.3f\n", lxt[i].ans);
if(team[teamname]==1)lxt[i].ans+=36.0;
else if(team[teamname]==2)lxt[i].ans+=27.0;
else if(team[teamname]==3)lxt[i].ans+=18.0; //printf(" %.3f\n", lxt[i].ans);
for(int j = 0;j<num2; ++j)
cin>>a[j];
if(num2>=3)
{
sort(a, a+num2, cmp1);
lxt[i].ans+=1.5*max(0.0, 1.0*(a[2]-1200)/100);//printf(" %.3f\n", lxt[i].ans);
}
if(sex=="F")lxt[i].ans+=33.0;
// printf(" %.3f\n", lxt[i].ans);
}
sort(lxt, lxt+n, cmp);
for(int i = 0; i<min(m, n); ++i)
{
cout<<lxt[i].name;
printf(" %.3f\n", lxt[i].ans);
}
}
return 0;
}