Program | GIFT.C, GIFT.CPP, GIFT.PAS |
This problem involves determining, for a group of gift-giving friends, how
much more each person gives than they receive (and vice versa for those that
view gift-giving with cynicism).
In this problem each person sets aside some money for gift-giving and divides
this money evenly among all those to whom gifts are given.
However, in any group of friends, some people are more giving than others (or
at least may have more acquaintances) and some people have more money than others.
Given a group of friends, the money each person in the group spends on gifts,
and a (sub)list of friends to whom each person gives gifts; you are to write
a program that determines how much more (or less) each person in the group gives
than they receive.
Sample Input
5
dave laura owen vick amr
dave 200 3 laura owen vick
owen 500 1 dave
amr 150 2 vick owen
laura 0 2 amr vick
vick 0 0
3
liz steve dave
liz 30 1 steve
steve 55 2 liz dave
dave 0 2 steve liz
0
Sample Output
dave 302
laura 66
owen -359
vick 141
amr -150
liz -3
steve -24
dave 27