#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
struct gitf {
string name;
int money0; //定义一个简单的结构体,表示名字,初始的金钱,最后的金钱
int money;
}a[10];
int main()
{
freopen("gift1.in", "r", stdin);
freopen("gift1.out", "w", stdout);
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i].name; //读入名字
for (int i = 0; i < n; i++) {
string s; int amount; int people;
cin >> s; cin >> amount; cin >> people; //读入每个人的初始金钱和要分钱的人数
int spent;
if (people == 0) spent=0;
else spent = amount / people;
//cout << spent << endl;
for (int j = 0; j < n; j++)
if (a[j].name == s) {
a[j].money0 = amount;
a[j].money += amount; //注意这里的money不要 ” = ” amount
a[j].money -= people*spent;
}
for (int j = 0; j < people; j++) {
string recer;
cin >> recer;
//cout << recer << endl;
for (int x = 0; x < n; x++) if (a[x].name == recer) a[x].money += spent; //分钱
}
}
for (int i = 0; i < n; i++) {
cout << a[i].name << " " << (a[i].money - a[i].money0) << endl; //打印
}
return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-1294775.html