fork download
  1. #include<iostream>
  2. #include<vector>
  3. #include<string>
  4.  
  5. using namespace std;
  6.  
  7. int getIndex(char);
  8.  
  9. int getIndex(char asd) {
  10. int x = static_cast<int>(asd) - 97;
  11. return x;
  12. }
  13.  
  14. int main() {
  15. int t;
  16. cin >> t;
  17. while (t--) {
  18. int sum = 0;
  19. vector<int> price(26);
  20. vector<int> flag(26, 0);
  21. string str;
  22. for (int i = 0; i < 26; i++) {
  23. cin >> price[i];
  24. }
  25. cin >> str;
  26. for (unsigned int j = 0; j < str.size(); j++) {
  27. flag[getIndex(str[j])]++;
  28. }
  29. for (int k = 0; k < 26; k++) {
  30. if (flag[k] == 0) { sum += price[k]; }
  31. }
  32. cout << sum << endl;
  33. }
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 15240KB
stdin
2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
abcdefghijklmopqrstuvwz
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
thequickbrownfoxjumpsoverthelazydog
stdout
63
0