Codeforces Round #FF (Div. 2), problem: (B) DZY Loves Strings editorial: http://codeforces.com/blog/entry/13036
Codeforces Round #FF (Div. 2), problem: (B) DZY Loves Strings solution: http://ideone.com/tU5hQ2
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int main() { char s[1005]; int k, a[30]={0}, ma=0, cnt=0; scanf("%s", s); scanf("%d", &k); for(int i=0; i<26; i++) { scanf("%d", &a[i]); if(a[i]>ma) ma=a[i]; } for(int i=0; i<strlen(s); i++) cnt+=a[s[i]-97]*(i+1); for(int i=strlen(s)+1; i<=strlen(s)+k; i++) cnt+=ma*i; printf("%d", cnt); return 0; }
No comments:
Post a Comment