Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- map<string, double> cities;
- while (true) {
- cin.ignore();
- string city;
- getline(cin, city);
- city.erase(city.find_last_not_of(' ') + 1);
- if (city.empty()) {
- break;
- }
- double price;
- int quantity;
- cin >> price >> quantity;
- cities[city] += price * quantity;
- }
- for (auto& c : cities) {
- cout << c.first << ' ' << c.second << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement