Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define endl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(), x.end()
- int main() {
- ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
- int test;
- cin >> test;
- while (test--) {
- int n;
- cin >> n;
- char chars[n];
- ll costs[n];
- for (int i = 0; i < n; i++) {
- cin >> chars[i] >> costs[i];
- }
- int m;
- cin >> m;
- string s;
- ll total_price = 0;
- cin.ignore();
- for (int i = 0; i < m; i++) {
- getline(cin, s);
- for (int j = 0; j < sz(s); j++) {
- for (int k = 0; k < n; k++) {
- if (chars[k] == s[j]) total_price += costs[k];
- }
- }
- }
- cout << fixed << setprecision(2) << total_price / 100.0 << '$' << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement