include iostream include map using namespace std int main int wordcoun

 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
#include <iostream>
#include <map>
using namespace std;
int main()
{
int wordcount, texts;
cin >> wordcount >> texts;
map<string,int> words;
while(wordcount--)
{
string word;
int val;
cin >> word >> val;
words[word]=val;
}
while (texts--)
{
int res=0;
string w;
while(cin>>w, w!=".")
res+=words[w];
cout << res << endl;
}
}