Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<algorithm>
  3. using namespace std;
  4.  
  5. struct data
  6. {
  7. string str;
  8. int give;
  9. int recieve;
  10. };
  11.  
  12. int main()
  13. {
  14. int t;
  15. cin>>t;
  16. while(1)
  17. {
  18. data arr[12];
  19. for(int i=0; i<t; i++)
  20. {
  21. cin>>arr[i].str;
  22. arr[i].recieve=0;
  23. }
  24. for(int i=0; i<t; i++)
  25. {
  26. string name;
  27. string name2;
  28. cin>>name;
  29. int j,n;
  30. for(int j=0; j<t; j++)
  31. {
  32. if(name==arr[j].str)
  33. {
  34. cin>>arr[j].give;
  35. cin>>n;
  36. if(n!=0)
  37. {
  38. int z=arr[j].give/n;
  39. arr[j].give=z*n;
  40. arr[j].recieve=arr[j].recieve-arr[j].give;
  41. for(int k=0; k<n; k++)
  42. {
  43. cin>>name2;
  44. for(int m=0; m<t; m++)
  45. {
  46. if(name2==arr[m].str)
  47. {
  48. //cout<<arr[m].str<<endl;
  49. arr[m].recieve+=z;
  50. //cout<<arr[m].recieve<<endl;
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58.  
  59. for(int i=0; i<t; i++)
  60. {
  61. cout<<arr[i].str<<" "<<arr[i].recieve<<endl;
  62. }
  63.  
  64. if(cin>>t) cout<<endl;
  65. else break;
  66. }
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement