time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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?

Input

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.

Output

Print a single integer — the largest possible value of the resulting string DZY could get.

Sample test(s)
Input
abc
3
1 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
Output
41
Note

In the test sample DZY can obtain "abcbbc",
value = 1·1 + 2·2 + 3·2 + 4·2 + 5·2 + 6·2 = 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 1005 const 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;
}

最新文章

  1. Windows 2008 - 由于管理员设置的策略,该磁盘处于脱机状态
  2. SQL Server 2012提供的OFFSET/FETCH NEXT与Row_Number()对比测试(转)
  3. 在Windows系统下用命令把应用程序添加到系统服务
  4. XAMARIN +VS2015 ANDROID 开发判断gps 是否打开。
  5. Maven基础配置--nexus私服配置
  6. 清北学堂2017NOIP冬令营入学测试P4749 F’s problem(f)
  7. Java开发、网络爬虫、自然语言处理、数据挖掘简介
  8. 关于VS2010“ADO.NET Entity Data Model模板丢失或者添加失败问题
  9. &quot;hadoop namenode -format&quot;命令的作用和影响的文件
  10. Echarts双轴图的配置.
  11. sec:authorize 标签 通过不通过权限例子
  12. linux下删除内核
  13. ios 刷新BUG
  14. DELPHI删除记录文件
  15. 微信公众号中ip白名单用谁的ip
  16. __x__(47)0910第六天__IE6到IE11对于包含中文路径的png显示问题
  17. python smtp邮件
  18. 几种stl的应用
  19. 网站开发,推荐使用SuperSlide 插件-Tab标签切换,图片滚动,无缝滚动,焦点图
  20. Android 音视频深入 六 使用FFmpeg播放视频(附源码下载)

热门文章

  1. nyoj--745--蚂蚁的难题(二)
  2. [BZOJ 3363] Cow Marathon
  3. UVA-12578 10:6:2 计算几何 模拟
  4. 常用GC算法
  5. Fabric quickly
  6. wcf 学习程序
  7. Codeforces Round #453
  8. Oracle数据库实例
  9. MySQL 5.6 Reference Manual-14.2 InnoDB Concepts and Architecture
  10. Django rest_framework API 随笔