Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- map <char, float> table;
- int test, n, m;
- string s;
- float pays;
- int main () {
- #ifndef ONLINE_JUDGE
- freopen("uva11340.inp", "r", stdin);
- #endif // ONLINE_JUDGE
- scanf("%d", &test);
- for (int itest = 0; itest<test; ++itest) {
- scanf("%d", &n); getline(cin, s);
- table.clear(); pays = 0.0;
- for (int i=0; i<n; ++i) {
- char chara; float cents;
- scanf("%c%f", &chara, ¢s);
- //cout << chara << " " << cents << endl;
- table[chara] = cents; getline(cin, s);
- }
- scanf("%d", &m); cin.ignore();
- for (int i=0; i<m; ++i) {
- getline(cin, s);
- int len = s.length();
- //cout << s << endl;
- for (int j=0; j<len; ++j) {
- if (table.find(s[j]) != table.end()) pays += table.find(s[j]) -> second;
- //cout << pays << " ";
- }
- }
- pays /= 100;
- printf("%.2lf$\n", pays);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment