fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,n,i;//,a[26],has[26];
  6. string s;
  7. cin>>t;
  8. while(t--)
  9. {
  10. long long sum=0;
  11. int a[26];
  12. for(i=0;i<26;i++)
  13. cin>>a[i];
  14.  
  15. /*for(i=0;i<26;i++)
  16. has[i]=0; */
  17. int has[26]={0};
  18.  
  19. cin>>s;
  20.  
  21. for(i=0;i<s.length();i++)
  22. has[s[i]-'a']++;
  23.  
  24. for(i=0;i<26;i++)
  25. {
  26. if(has[i]==0)
  27. sum+=a[i];
  28. }
  29. cout<<sum<<endl;
  30. }
  31.  
  32.  
  33. return 0;
  34. }
  35.  
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