-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprob_10295.cpp
51 lines (49 loc) · 934 Bytes
/
prob_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
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <climits>
#include <list>
#include <set>
#include <forward_list>
#define rep(i,a,b) for(i=a;i<b;++i)
#define vectIter(vect) for(auto &val: vect)
#define mapIter(map_) for(auto &val_: map_)
#define gc getchar_unlocked
using namespace std;
#define INF 999999999
struct functor{
bool operator()(const char* str1, const char* str2){
return strcmp(str1,str2)<0;
}
};
int main(){
int m,n;
int i,j,k;
scanf("%d%d",&m,&n);
map<string,int> salary;
string str;
while(m--){
cin >> str >> k;
salary[str]=k;
}
while(n--){
int sal=0;
while(getline(cin,str),str!="."){
stringstream stream(str);
while(stream>> str){
sal+=salary[str];
}
}
cout << sal <<endl;
}
}