1000分也挺水…我写的简洁又好看
看着1300挺难,还有dp…行吧,不管感觉水不水就稳定1300了。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char ch[1020];
int w[27], k;
int main(){
scanf("%s",ch);
int len = strlen(ch);
cin >> k;
int maxn = -1;
for(int i = 0; i < 26; ++i){
cin >> w[i];
maxn = max(maxn, w[i]);
}
int res = 0;
for(int i = 0, j= 1; ch[i]; ++i,++j)
res += j*w[ch[i]-'a'];
while(k--)
res += ++len*maxn;
cout << res << endl;
return 0;
}