-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10295.cpp
60 lines (58 loc) · 1.05 KB
/
10295.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* @author : Maruf Tuhin
* @School : CUET CSE 11
* @Topcoder : the_redback
* @Codeforces : the_redback
* @UVA : Redback
* @link : http://www.fb.com/maruf.2hin
*/
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
using namespace std;
#define inf HUGE_VAL
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
main()
{
//ios_base::sync_with_stdio(false);
map<string,int>mp;
string s;
string ss;
int ret=0;
int n,k,l,r,i;
int tc,t=1;
scanf("%d",&n);
scanf("%d",&tc);
while(n--)
{
cin>>s>>k;
mp[s]=k;
}
while(tc--)
{
l=0;
while(cin>>s)
{
if(s[0]=='.')
break;
if(mp.find(s)!=mp.end())
{
l+=mp[s];
}
}
cout<<l<<"\n";
}
return 0;
}