Codeforces Round #255(Div. 2)
来源:互联网 发布:mongodb与mysql区别 编辑:程序博客网 时间:2024/05/22 12:56
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function f(s), where
Now DZY has a string s. He wants to insert k lowercase letters into this string in order to get the largest possible value of the resulting string. Can you help him calculate the largest possible value he could get?
The first line contains a single string s (1 ≤ |s| ≤ 103).
The second line contains a single integer k (0 ≤ k ≤ 103).
The third line contains twenty-six integers from wa to wz. Each such number is non-negative and doesn't exceed 1000.
Print a single integer — the largest possible value of the resulting string DZY could get.
abc31 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41
题意:插入给定数量的字符,求出目标字符串的最大权值
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){ char str[1005]; int k,i,sum,len; int a[27]; scanf("%s",str); len=strlen(str); scanf("%d",&k); for(i=0;i<26;i++) scanf("%d",&a[i]); sum=0; for(i=0;i<len;i++) sum+=a[str[i]-'a']*(i+1); sort(a,a+26); for(i=len+1;i<len+k+1;i++) sum+=i*a[25]; printf("%d\n",sum); return 0;}
- Codeforces Round #255(Div. 2)
- Codeforces Round #255 (Div. 2) C
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- Codeforces Round #110 (Div. 2)
- Codeforces Round #122 (Div. 2)
- Codeforces Round #121 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #125 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #127 (Div. 2)
- Codeforces 446A —— DZY Loves Sequences(DP)
- 被遗忘的黑莓,你还活得好么?
- 黑马程序员 类的方法中参数的传递
- day day up--Java设计模式之单例模式
- Ubuntu Kylin 14.04 LTS使用体验
- Codeforces Round #255(Div. 2)
- 5.1.5 Binary Tree Level Order Traversal II
- 期末总结
- iOS 获取 当前设备 可用内存 及当前 应用 所占内存 (转)
- 5.1.6 Binary Tree Zigzag Level Order Traversal
- Codeforces Round #255 (Div. 2) C
- Codeforces Round #FF (Div. 2):Problem A - DZY Loves Hash
- 7.13ACM暑期集训开始
- Hibernate的一些学习记录