Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include <iostream>
- #include <map>
- #include <queue>
- using namespace std;
- int main()
- {
- map<string, int> mines;
- queue<string> order;
- while (true)
- {
- string resource;
- cin >> resource;
- if (resource == "stop")
- {
- break;
- }
- int quantity;
- cin >> quantity;
- if (mines.find(resource) == mines.end())
- {
- order.push(resource);
- }
- mines[resource] += quantity;
- }
- while (!order.empty())
- {
- string element = order.front();
- cout << element << " -> " << mines[element] << endl;
- order.pop();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement