#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#include<cstring>
using namespace std;
int n,m,l[105],cir[105][105],cnt;
int ans,cost[10005],pos[10005];
struct Person{
int num,t,p;
}p[10005];
bool cmp(const Person &a,const Person &b)
{
return a.t<b.t;
}
bool cmp1(int a,int b)
{
return pos[a]<pos[b];
}
map<string,int>name;
map<int,string>fname;
vector<int>cirp[10005];
void solve(int x)
{
vector<Person>v;
if(ans>p[x].t)
cost[x]=ans-p[x].t;
else{
ans=p[x].t;
cost[x]=0;
}
ans+=p[x].p;
cout<<fname[x]<<endl;
for(int i=0;i<cirp[x].size();i++)
{
int k=cirp[x][i];
for(int j=1;j<=l[k];j++)
if(pos[cir[k][j]]>pos[x]&&cost[cir[k][j]]==-1)
v.push_back({cir[k][j],pos[cir[k][j]],p[cir[k][j]].p});
}
sort(v.begin(),v.end(),cmp);
for(int i=0;i<v.size();i++)
{
if(ans>=p[v[i].num].t)
cost[v[i].num]=ans-p[v[i].num].t;
else
break;
ans+=v[i].p;
cout<<fname[v[i].num]<<endl;
}
}
string ss[105][105];
int main()
{
memset(cost,-1,sizeof(cost));
string s;
cin>>n>>m;
for(int i=1;i<=m;i++)
{
scanf("%d",&l[i]);
for(int j=1;j<=l[i];j++)
cin>>ss[i][j];
}
for(int i=1;i<=n;i++)
{
cin>>s;
if(!name[s])
{
name[s]=++cnt;
fname[cnt]=s;
}
int num=name[s];
scanf("%d%d",&p[num].t,&p[num].p);
if(p[num].p>60) p[num].p=60;
p[num].num=num;
}
for(int i=1;i<=m;i++)
{
for(int j=1;j<=l[i];j++)
{
cir[i][j]=name[ss[i][j]];
cirp[name[ss[i][j]]].push_back(i);
}
}
sort(p+1,p+1+n,cmp);
for(int i=1;i<=n;i++)
pos[p[i].num]=i;
for(int i=1;i<=m;i++)
sort(cir[i]+1,cir[i]+1+l[i],cmp1);
for(int i=1;i<=n;i++)
{
int num=p[i].num;
if(cost[num]==-1)
solve(num);
}
ans=0;
for(int i=1;i<=n;i++)
ans+=cost[i];
printf("%.1lf",(double)ans/n);
return 0;
}
09-11
595
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
07-16
605
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)