/***
Md. Namzul Hasan
Shahjalal University of Science & technology,sylhet.
hasan08sust@gmail.com
verdict: accepted
***/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cctype>
#include<sstream>
#include<stdlib.h>
#include<map>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
map <string, in> mp ;
string str , data ;
in job , descript, salary ;
int main()
{
while(cin>>job>>descript)
{
for(in i=1 ;i <=job ; i++)
{
cin>>str>>salary ;
mp[str] = salary ;
}
for(in i=1 ; i<=descript ; i++)
{
in k =0 ;
while(cin>>data)
{
in len = data.size() ;
if(data[0]=='.' && len==1)
break ;
if(mp.find(data)!=mp.end())
{
k = k + mp[data] ;
}
}
pf("%d\n",k) ;
}
}
return 0 ;
}
No comments:
Post a Comment