Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define itloop(it,x) for(auto it=x.begin();it!=x.end();it++)
- #define reloop(i,e,b) for(auto i=e;i>=b;i--)
- #define loop(i,b,e) for(auto i=b;i<=e;i++)
- #define ALL(x) x.begin(),x.end()
- #define SZ(x) x.size()
- #define PB push_back
- #define MP make_pair
- #define F first
- #define S second
- #define sf scanf
- #define pf printf
- typedef long long LL;
- typedef vector<int> VI;
- typedef vector<LL> VLL;
- typedef pair<int,int> PI;
- typedef pair<LL,LL> PL;
- const int N=1e5+1;
- LL ans;
- int n,c,k,cost;
- string s;
- vector<string> words,msg;
- map<string,int> m;
- int main()
- {
- sf("%d %d %d",&n,&k,&c);
- loop(i,1,n) {
- cin >> s;
- words.PB(s);
- }
- loop(i,0,n-1) {
- scanf("%d",&cost);
- m[words[i]] = cost;
- }
- loop(i,0,k-1) {
- int sz,x,mn=1e8;
- sf("%d",&sz);
- loop(j,0,sz-1) {
- sf("%d",&x);
- mn = min(mn,m[words[x-1]]);
- }
- loop(j,0,sz-1)
- m[words[x-1]] = mn;
- }
- loop(i,1,c) {
- cin >> s;
- ans += m[s];
- }
- pf("%lld",ans);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement