-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa-11340.cpp
More file actions
52 lines (40 loc) · 1.02 KB
/
UVa-11340.cpp
File metadata and controls
52 lines (40 loc) · 1.02 KB
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
#include <iostream>
#include <cstdio>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h> // here we have all the STL we need, including istringstream and ostringstream
#define ALL(x) x.begin(), x.end()
#define FAST std::cin.tie(0); ios::sync_with_stdio(false); std::cout.tie(0);
int main(void) {
FAST
int N;
cin >> N;
int K;
while (N--) {
cin >> K;
unordered_map<char, int> m;
char c;
int v;
while (K--) {
cin >> c >> v;
m[c] = v;
}
int M;
cin >> M;
string line;
cin.ignore();
int total = 0;
while (M--) {
getline(cin, line);
for (int i = 0; i < line.size(); i++) {
if (m.find(line[i]) != m.end()) {
total += m[line[i]];
}
}
}
cout << total / 100 << "." << setw(2) << setfill('0') << total % 100 << "$" << endl;
}
return 0;
}