Please help...
Code: Select all
#include <stdio.h>
#include <string>
#include <hash_map>
using namespace std;
const int maxn = 11;
int n,test;
hash_map<string,int> person;
char names[maxn][15];
char name[15];
int main()
{
int x,y;
int ile,cash;
while (scanf ("%d",&n)==1)
{
person.clear();
for (x=0; x<n; ++x)
{
scanf ("%s",&names[x]);
person[names[x]]=0;
}
for (x=0; x<n; ++x)
{
scanf ("%s%d%d",&name,&cash,&ile);
if (ile) person[name]-=cash-cash%ile;
else person[name]+=cash;
for (y=0; y<ile; ++y)
{
scanf ("%s",&name); person[name]+=cash/ile;
}
}
if (test++) printf ("\n");
for (x=0; x<n; ++x)
{
printf ("%s %d\n",names[x],person[names[x]]);
}
}
return 0;
}