#include<iostream>
#include<string>
using namespace std;
string job[1000];
int salary[1000];
int main()
{
register int m,n,i,j=0,total,sal;
string jbs;
//freopen("in.txt","r",stdin);
scanf("%d%d",&m,&n);
for(i=0;i<m;i++)
cin>>job[i]>>salary[i];
while(j^n)
{
total=0;
while(1)
{
cin>>jbs;
sal=0;
if(jbs==".")
{
j++;
break;
}
for(i=0;i<m;i++)
if(job[i]==jbs)
{
sal=salary[i];
break;
}
total+=sal;
}
printf("%d\n",total);
}
return 0;
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.