-
Notifications
You must be signed in to change notification settings - Fork 2
/
11340.cpp
42 lines (38 loc) · 819 Bytes
/
11340.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
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
string line;
char dummy;
long long val, total, cases, lines;
cin >> cases;
while(cases--)
{
map<char, long long> values;
total = 0;
cin >> lines;
cin.ignore();//Ignore trailing \n
//Get pair characters and values
while(lines--)
{
dummy = cin.get();
cin >> val;
values[dummy] = val;
cin.ignore();//Ignore trailing \n
}
cin >> lines;
cin.ignore();//Ignore trailing \n
//Iterate through the lines character by character
while(lines--)
{
getline(cin, line);
for(string::iterator s = line.begin(); s != line.end(); s++)
if(values.count(*s))
total += values[*s];
}
cout << total / 100 << '.' << (total/10)%10 << total %10 << '$' << endl;
}
return 0;
}