Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- map<string,int> gr;
- string arr[100005];
- int cost[100005];
- int gcost[100005];
- int n,k,m;
- int main()
- {
- cin >> n >> k >> m;
- int i;
- for(i=0;i<n;i++)
- cin >> arr[i];
- for(i=0;i<n;i++)
- cin >> cost[i];
- for(i=0;i<k;i++)
- {
- gcost[i]=(1<<30);
- int x;
- cin >> x;
- while(x--)
- {
- int z;
- cin >> z; z--;
- gcost[i]=min(gcost[i],cost[z]);
- gr[arr[z]]=i;
- }
- }
- long long ans=0;
- for(i=0;i<m;i++)
- {
- string x;
- cin >> x;
- ans+=gcost[gr[x]];
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement