#include<bits/stdc++.h>
using namespace std;
struct jewel{
string n;
bool c=false;
int p;
};
int main(){
int n,k,p=0;
jewel b[1001]={};
string s;
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>b[i].n>>b[i].p;
}
for(int i=0;i<k;i++){
cin>>s;
for(int j=0;j<n;j++){
if(b[i].n==s){
(b[i].c)?(p+=b[i].p): (b[i].c=true);
}
}
}
cout<<p;
return 0;
}
为什么我用结构体过不了!!!