theo830

money

Apr 7th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<list>
  4. #include<algorithm>
  5. #include <iomanip>
  6. #include <map>
  7. using namespace std;
  8. int main(){
  9. int a;
  10. cin>>a;
  11. map<string,int>m;
  12. int b;
  13. string w;
  14. int x;
  15. double t=0;
  16. int k=0;
  17. for(int i=0;i<a;i++){
  18. cin>>b;
  19. if(b == 1){
  20. cin>>w>>x;
  21. if(m[w] == 0){
  22. k++;
  23. }
  24. m[w] = m[w] + x;
  25. t = t + x;
  26. }
  27. else if(b == 2){
  28. cin>>w;
  29. t = t - m[w];
  30. m[w] = 0;
  31. k--;
  32. }
  33. else{
  34. cin>>w;
  35. cout<<m[w]<<endl;
  36. }
  37. }
  38. if(k != 0){
  39. t = t / k;
  40. }
  41. cout<<setprecision(2)<<fixed<<t;
  42. return 0;
  43. }
Add Comment
Please, Sign In to add comment