Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define ff first
- #define ss second
- #define pb push_back
- int main()
- {
- int n, m;
- cin>>n>>m;
- vector<string> c(n), d(m);
- vector<int> p(m+1);
- for(auto &e: c) cin>>e;
- for(auto &e: d) cin>>e;
- for(auto &e: p) cin>>e;
- map<string, int> mp;
- for(int i=0; i<m; i++)
- mp[d[i]] = i+1;
- ll int ans = 0;
- for(auto e: c)
- ans += p[mp[e]];
- cout<<ans<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment