原题链接
#include<bits/stdc++.h>
using namespace std;
map<string, pair<int ,int > >cus;
map<string,int >fri;
string a[10000];
int main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++)
{
int k;
cin>>k;
while(k--)
{
string s;
cin>>s;
fri[s]=i;
}
}
for(int i=0;i<n;i++)
{
int x,y;
cin>>a[i]>>x>>y;
cus[a[i]]={x,min(60,y)};
}
int now=0;
int sum=0;
for(int i=0;i<n;i++)
{
auto tmp=cus[a[i]];
if(tmp.first==-1) continue;
cout<<a[i]<<endl;
sum+=max(0,now-tmp.first);
now=max(now,tmp.first)+tmp.second;
for(int j=i+1;j<n;j++)
{
auto tmp=cus[a[j]];
auto x=fri.find(a[i]),y=fri.find(a[j]);
if(x!=fri.end()&&y!=fri.end())
{
if(tmp.first!=-1&&x->second==y->second&&tmp.first<=now)
{
cout<<a[j]<<endl;
cus[a[j]].first=-1;
sum+=(now-tmp.first);
now+=tmp.second;
}
}
}
}
printf("%.1f",1.0*sum/n);
return 0;
}