Advertisement
Saleh127

Untitled

Apr 29th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main()
  5. {
  6. ll t,i,j,k,l;
  7. cin>>t;
  8. while(t--)
  9. {
  10. ll b,d,e,f;
  11. double ans=0,value;
  12. char c;
  13. map<char, double>store;
  14. map<char, double>::iterator khoj;
  15. cin>>b;
  16. for(i=0;i<b;i++)
  17. {
  18. cin>>c>>value;
  19. store[c]=value;
  20. }
  21. cin>>d;
  22. cin.ignore();
  23. while(d--)
  24. {
  25. string a;
  26. getline(cin,a);
  27. l=a.size();
  28. for(j=0;j<l;j++)
  29. {
  30. khoj=store.find(a[j]);
  31. if(khoj != store.end())
  32. {
  33. ans+= khoj->second;
  34. }
  35. }
  36. }
  37. ans=ans/100;
  38. printf("%0.2lf$\n",ans);
  39. store.clear();
  40. }
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement