silentkiler029

UVa-11340

Jun 29th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. /*  BISMILLAHIR-RAHMANIR-RAHIM
  2.  ____________________________________
  3. |                                    |
  4. |       SHANTO_SUST_SWE-19_029       |
  5. |____________________________________|
  6. */
  7.  
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std;
  11.  
  12. #define ll long long
  13. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  14. #define pb push_back
  15. #define Pi acos(-1)
  16. #define r0 return 0
  17. #define endl "\n"
  18. #define show(x) cout << x << endl
  19. #define take(x) cin >> x
  20. #define debug 1
  21.  
  22. int main()
  23. {
  24.     long long T, k, m, x, temp;
  25.     cin >> T;
  26.  
  27.     char c;
  28.     long long i, n, j;
  29.  
  30.     while(T--) {
  31.         cin >> k;
  32.         vector < long long > v(256);
  33.  
  34.         for(i = 0; i < k; i++) {
  35.             cin >> c;
  36.             cin >> x;
  37.             temp = (long long)c;
  38.             getchar();
  39.             v[temp] = x;
  40.         }
  41.  
  42.         cin >> m;
  43.         getchar();
  44.         long long sum = 0;
  45.         for(i = 0; i < m; i++) {
  46.             string s;
  47.             getline(cin, s);
  48.             n = s.size();
  49.  
  50.             for(j = 0; j < n; j++) {
  51.                 temp = (long long)s[j];
  52.                 sum += v[temp];
  53.             }
  54.             s.clear();
  55.         }
  56.         if(sum % 100 < 10) cout << sum / 100 << ".0" << sum % 100 << "$" << endl;
  57.         else cout << sum / 100 << "." << sum % 100 << "$" << endl;
  58.         v.clear();
  59.     }
  60.  
  61.     r0;
  62. }
  63.  
  64. //ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment