-
Notifications
You must be signed in to change notification settings - Fork 0
/
119 - Greedy Gift Givers.cpp
56 lines (56 loc) · 1.36 KB
/
119 - Greedy Gift Givers.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
||-----------------------------------||
|| Rahat Khan Pathan ||
|| BGC Trust University ||
|| Department of CSE ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define pub push_back
#define pi 3.14159265359
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define pi pair<ll,ll>
#define vpair vector<pair<ll,ll> >
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define minus cout<<-1<<endl
using namespace std;
int main()
{
ll n,c=0;
while(cin>>n)
{
string name[n+1],a;
ll i,money,person,j,even;
map<string,ll>give,take;
for(i=0;i<n;i++)
{
cin>>name[i];
}
for(i=0;i<n;i++)
{
cin>>a>>money>>person;
even=(person==0)? 0 : money/person;
give[a]+=even*person;
for(j=0;j<person;j++)
{
cin>>a;
take[a]+=even;
}
}
if(c)
{
cout<<endl;
}
c++;
for(i=0;i<n;i++)
{
cout<<name[i]<<" "<<take[name[i]]-give[name[i]]<<endl;
}
}
return 0;
}