D_L3

SDA - 2019 2020 - test5 - task 1

Dec 11th, 2023
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <unordered_map>
  7.  
  8. using namespace std;
  9.  
  10. unordered_map<string, int> taxes;
  11.  
  12. int main() {
  13.     int n, m;
  14.     cin >> n >> m;
  15.     string town;
  16.     int tax;
  17.    
  18.     for(int i = 0; i < n; i++){
  19.         cin >> town >> tax;
  20.         taxes[town] = tax;
  21.     }
  22.     long long sum = 0;
  23.     for(int i = 0; i < m; i++){
  24.         cin >> town;
  25.         sum += taxes[town];
  26.     }
  27.     cout << sum;
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment