- 贪婪的送礼者
- 2017-07-25 16:36:35 @
include <iostream>
include <cstdio>
include <cstring>
include <string>
using namespace std;
struct
{
char name[20];
int money;
}a[10];
int main ()
{
int n;
cin >> n;
for(int i = 0;i<n;++i)
{
scanf("%s",a[i].name);
a[i].money = 0;
}
char k[20];
int chu,shu;
while(1)
{
scanf("%s",k);
scanf("%d %d",&chu,&shu);
if(chu == 0 && shu == 0) break;
for(int i = 0;i<n;++i)
{
if(strcmp(a[i].name,k)==0)
{
a[i].money -= chu -(chu%shu);
break;
}
}
for(int i = 0;i<shu;++i)
{
scanf("%s",k);
for(int t = 0;t<n;++t)
{
if(strcmp(a[t].name,k)==0)
{
a[t].money += chu/shu;
break;
}
}
}
}
for(int i = 0;i<n;++i)
{
printf("%s %d\n",a[i].name,a[i].money);
}
return 0;
}