Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_map>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- vector<string> resources;
- unordered_map<string, int> Quantity;
- string resource;
- while (cin >> resource && resource != "stop")
- {
- if (Quantity.find(resource) == Quantity.end())
- {
- resources.emplace_back(resource);
- Quantity.emplace(resource, 0);
- }
- int quantity;
- cin >> quantity;
- Quantity[resource] += quantity;
- }
- for (const auto &item : resources)
- {
- const auto& it = Quantity.find(item);
- cout << it->first << " -> " << it->second << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement