Advertisement
Guest User

7. Miners

a guest
Oct 22nd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. include <iostream>
  2. #include <map>
  3. #include <queue>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. map<string, int> mines;
  10. queue<string> order;
  11. while (true)
  12. {
  13. string resource;
  14. cin >> resource;
  15. if (resource == "stop")
  16. {
  17. break;
  18. }
  19.  
  20. int quantity;
  21. cin >> quantity;
  22.  
  23. if (mines.find(resource) == mines.end())
  24. {
  25. order.push(resource);
  26. }
  27.  
  28. mines[resource] += quantity;
  29. }
  30.  
  31. while (!order.empty())
  32. {
  33. string element = order.front();
  34. cout << element << " -> " << mines[element] << endl;
  35. order.pop();
  36. }
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement