fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4.  
  5. long long sum, value[128];
  6.  
  7. int n, q, t;
  8.  
  9. char c, s[10010];
  10.  
  11.  
  12. int main() {
  13.  
  14. scanf("%d", &t);
  15.  
  16. while (t--) {
  17.  
  18. scanf("%d", &n);
  19.  
  20. memset(value, 0, sizeof(value));
  21.  
  22. while (n--) {
  23.  
  24. getchar(); //while (getchar() != '\n') ;
  25.  
  26. c = getchar();
  27.  
  28. scanf("%lld", &value[c]);
  29. }
  30.  
  31. scanf("%d", &q);
  32.  
  33. getchar(); //while (getchar() != '\n') ;
  34.  
  35. for (sum = 0; q--; ) {
  36.  
  37. gets(s);
  38.  
  39. for (int i = 0; s[i]; i++) sum += value[ s[i] ];
  40. }
  41.  
  42. printf("%.2lf$\n", 0.01 * sum);
  43. }
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0s 3352KB
stdin
1
7
a 3
W 10
A 100
, 10
k 7
. 3
I 13
7
ACM International Collegiate Programming Contest (abbreviated
as ACM-ICPC or just ICPC) is an annual multi-tiered competition
among the universities of the world. The ICPC challenges students
to set ever higher standards of excellence for themselves
through competition that rewards team work, problem analysis,
and rapid software development.
From Wikipedia.
stdout
3.74$