Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<algorithm>
- using namespace std;
- struct data
- {
- string str;
- int give;
- int recieve;
- };
- int main()
- {
- int t;
- cin>>t;
- while(1)
- {
- data arr[12];
- for(int i=0; i<t; i++)
- {
- cin>>arr[i].str;
- arr[i].recieve=0;
- }
- for(int i=0; i<t; i++)
- {
- string name;
- string name2;
- cin>>name;
- int j,n;
- for(int j=0; j<t; j++)
- {
- if(name==arr[j].str)
- {
- cin>>arr[j].give;
- cin>>n;
- if(n!=0)
- {
- int z=arr[j].give/n;
- arr[j].give=z*n;
- arr[j].recieve=arr[j].recieve-arr[j].give;
- for(int k=0; k<n; k++)
- {
- cin>>name2;
- for(int m=0; m<t; m++)
- {
- if(name2==arr[m].str)
- {
- //cout<<arr[m].str<<endl;
- arr[m].recieve+=z;
- //cout<<arr[m].recieve<<endl;
- }
- }
- }
- }
- }
- }
- }
- for(int i=0; i<t; i++)
- {
- cout<<arr[i].str<<" "<<arr[i].recieve<<endl;
- }
- if(cin>>t) cout<<endl;
- else break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement