/*
ID:wconvey1
TASK:gift1
LANG:C++
*/
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
struct node{
char s[16];
int m;
}q[15];
int main()
{
freopen("gift1.in","r",stdin);
freopen("gift1.out","w",stdout);
int n;
scanf("%d",&n);
{
int i,j,k,a,b,add;
char temp[16];
for(i=1;i<=n;i++)
{
scanf("%s",q[i].s);
q[i].m=0;
}
for(i=1;i<=n;i++)
{
scanf("%s",temp);
scanf("%d %d",&a,&b);
if(b!=0)
add=a/b;
if(b!=0)
for(j=1;j<=n;j++)
if(!strcmp(temp,q[j].s))
{ q[j].m+=a%b-a; break; }
for(j=1;j<=b;j++)
{
scanf("%s",temp);
for(k=1;k<=n;k++)
if(!strcmp(temp,q[k].s))//k搞成i
{ q[k].m+=add; break;}
}
}
for(i=1;i<=n;i++)//1搞成i了
printf("%s %d\n",q[i].s,q[i].m);
}//*************************************
return 0;
}
USACO 1.1.2 Greedy Gift Givers
最新推荐文章于 2024-09-01 16:42:17 发布