Advertisement
juanjo12x

UVA_11340_Newspaper

Aug 10th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string>
  6. #include <cctype>
  7. #include <stack>
  8. #include <queue>
  9. #include <list>
  10. #include <vector>
  11. #include <map>
  12. #include <set>
  13. #include <sstream>
  14. #include <stdlib.h>
  15. #include <cmath>
  16. #define LL unsigned long long
  17. using namespace std;
  18.  
  19. int main() {
  20.    int t,v,k,M;char line[10100];int cst;
  21.    char car;
  22.    scanf("%d",&t);
  23.    while(t--){
  24.     map<char,int> mp;cst=0;
  25.     scanf("%d",&k);getchar();
  26.     for(int i=0;i<k;i++){
  27.         scanf("%c %d",&car,&v);
  28.         mp[car]=v;
  29.         if (i<k-1) getchar();
  30.     }
  31.     scanf("%d",&M);getchar();
  32.     for(int i=0;i<M;i++){
  33.         gets(line);
  34.         int q=strlen(line);
  35.         for(int i=0;i<q;i++){
  36.             if(mp.find(line[i])==mp.end()){
  37.                 continue;
  38.             }else{
  39.                 cst+=mp[line[i]];
  40.             }
  41.         }
  42.         line[0]='\0';
  43.     }
  44.     printf("%d.%02d$\n",cst/100,cst%100);
  45.    
  46.    }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement