Ankit_132

B

Jul 1st, 2023
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. #define ll     long long
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7. #define ff     first
  8. #define ss     second
  9. #define pb     push_back
  10.  
  11. int main()
  12. {
  13.     int n, m;
  14.     cin>>n>>m;
  15.  
  16.     vector<string> c(n), d(m);
  17.     vector<int> p(m+1);
  18.    
  19.     for(auto &e: c)     cin>>e;
  20.     for(auto &e: d)     cin>>e;
  21.     for(auto &e: p)     cin>>e;
  22.  
  23.     map<string, int> mp;
  24.  
  25.     for(int i=0; i<m; i++)
  26.         mp[d[i]] = i+1;
  27.  
  28.     ll int ans = 0;
  29.  
  30.     for(auto e: c)
  31.         ans += p[mp[e]];
  32.  
  33.     cout<<ans<<"\n";
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment