Codeforces Round #FF (Div. 2):B. DZY Loves Strings
来源:互联网 发布:python遍历json对象 编辑:程序博客网 时间:2024/05/21 18:21
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letterc DZY knows its value wc. For each special strings = s1s2...s|s| (|s| is the length of the string) he represents its value with a functionf(s), where
Now DZY has a string s. He wants to insertk 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 towz. Each such number is non-negative and doesn't exceed1000.
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
题意:输入子串, 大小对应下面你输入的26个字母的大小, 后面再输入一个数字K,即你添加的过少个字母,要想结果最大。。就要找出你输入的26个字母对应数值大小最大的字母。。就像案列中的B和C是最大的, 所以就添加其。。
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<vector>#include<queue>#include<sstream>#include<cmath>using namespace std;#define f1(i, n) for(int i=0; i<n; i++)#define f2(i, m) for(int i=1; i<=m; i++)#define f3(i, n) for(int i=n; i>=0; i--)#define M 1005const int INF = 0x3f3f3f3f;int main(){ char s[1005]; int a, b, i, t=-1; __int64 d=0; int eng[27], c[1005]; scanf("%s", s); b=strlen(s); scanf("%d", &a); for(i=1; i<=26; i++) { scanf("%d",&eng[i]); if( t<eng[i] ) t = eng[i]; } for(i=0; i<b; i++) { c[i] = s[i]-'a'+1; d = d + eng[c[i]]*(i+1); } for(i=1; i<=a; i++) d = d + t*(b+i); printf("%I64d\n",d); return 0;}
- Codeforces Round #FF (Div. 2) Problem B DZY Loves Strings
- Codeforces Round #FF (Div. 2):B. DZY Loves Strings
- Codeforces Round #FF (Div. 2) B. DZY Loves Strings
- Codeforces Round #FF (Div. 2) 447B DZY Loves Strings
- Codeforces Round #FF (Div. 2)B. DZY Loves Strings
- Codeforces Round #FF (Div. 2)B. DZY Loves Strings
- Codeforces Round #FF (Div. 2/B)/Codeforces447B_ DZY Loves Strings(字符串处理)
- Codeforces Round #FF (Div. 2) B.DYZ Loves Strings
- Codeforces Round #FF (Div. 1) B. DZY Loves Modification
- Codeforces Round #FF (Div. 2) Problem A DZY Loves Hash
- Codeforces Round #FF (Div. 2):Problem A - DZY Loves Hash
- Codeforces Round #FF (Div. 2) A. DZY Loves Hash
- Codeforces Round #FF (Div. 2) A. DZY Loves Hash
- Codeforces Round #FF (Div. 2):C. DZY Loves Sequences
- Codeforces Round #FF (Div. 2) Problem C DZY Loves Sequences
- Codeforces Round #FF (Div. 2)C - DZY Loves Sequences
- Codeforces Round #FF (Div. 2)-C. DZY Loves Sequences
- Codeforces Round #FF (Div. 2)C. DZY Loves Sequences
- 7.13ACM暑期集训开始
- Hibernate的一些学习记录
- Codeforces 446C —— DZY Loves Fibonacci Numbers(线段树)
- 前台JS控制。net后台checkbox
- Linux 内核时间格式
- Codeforces Round #FF (Div. 2):B. DZY Loves Strings
- java发送http的get、post请求
- Codeforces Round #FF (Div. 2) B. DZY Loves Strings
- TAB CONTROL改成图标标签
- 黑马程序员_交通灯系统
- 面试算法(十六)合并两个排序的链表
- Codeforces Round #FF (Div. 2) A. DZY Loves Hash
- Codeforces Round #FF (Div. 2) A. DZY Loves Hash
- G4Studio简介2