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;
}

Codeforces Round #FF (Div. 2):B. DZY Loves Strings的更多相关文章

  1. DP Codeforces Round #FF (Div. 1) A. DZY Loves Sequences

    题目传送门 /* DP:先用l,r数组记录前缀后缀上升长度,最大值会在三种情况中产生: 1. a[i-1] + 1 < a[i+1],可以改a[i],那么值为l[i-1] + r[i+1] + ...

  2. Codeforces Round #254 (Div. 1) D - DZY Loves Strings

    D - DZY Loves Strings 思路:感觉这种把询问按大小分成两类解决的问题都很不好想.. https://codeforces.com/blog/entry/12959 题解说得很清楚啦 ...

  3. Codeforces Round #254 (Div. 1) D. DZY Loves Strings hash 暴力

    D. DZY Loves Strings 题目连接: http://codeforces.com/contest/444/problem/D Description DZY loves strings ...

  4. Codeforces Round #FF (Div. 1) B. DZY Loves Modification 优先队列

    B. DZY Loves Modification 题目连接: http://www.codeforces.com/contest/446/problem/B Description As we kn ...

  5. Codeforces Round #FF (Div. 1) A. DZY Loves Sequences 动态规划

    A. DZY Loves Sequences 题目连接: http://www.codeforces.com/contest/446/problem/A Description DZY has a s ...

  6. Codeforces Round #FF (Div. 2) D. DZY Loves Modification 优先队列

    D. DZY Loves Modification time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  7. Codeforces Round #FF (Div. 1) B. DZY Loves Modification

    枚举行取了多少次,如行取了i次,列就取了k-i次,假设行列单独贪心考虑然后相加,那么有i*(k-i)个交点是多出来的:dpr[i]+dpc[k-i]-i*(k-i)*p 枚举i取最大值.... B. ...

  8. Codeforces Round #FF (Div. 1) A. DZY Loves Sequences

    题目链接: http://www.codeforces.com/contest/446/problem/A 题解: dp1[x]表示以x结尾的最大严格升序连续串,dp2[x]表示以x开头的最大严格升序 ...

  9. Codeforces Round #FF (Div. 2)__E. DZY Loves Fibonacci Numbers (CF447) 线段树

    http://codeforces.com/contest/447/problem/E 题意: 给定一个数组, m次操作, 1 l r 表示区间修改, 每次 a[i] +  Fibonacci[i-l ...

随机推荐

  1. k8s traefik ingress tls

    使用下面的 openssl 命令生成 CA 证书: $ openssl req -newkey rsa:2048 -nodes -keyout tls.key -x509 -days 365 -out ...

  2. nginx 集群简述

    1.负载均衡介绍: 负载均衡是由多台服务器以对称的方式组成一个服务器集合,每台服务器都具有等价的地位,都可以单独对外提供服务而无须其他服务器的辅助.其工作模式为将外部发送来的请求均匀分配到对称结构中的 ...

  3. 使用纯 CSS 实现 Google Photos 照片列表布局

    文章太长,因为介绍了如何一步一步进化到最后接近完美的效果的,不想读的同学可以直接跳到最后一个大标题之后看代码.demo及原理就好,或者也可以直接看下面这个链接的源代码. 不过还是建议顺序读下去,因为后 ...

  4. WPF自定义动画控件 风机

      一:创建WPF项目 二:在项目下添加文件Themes,在此文件下添加新项 ”资源词典“取名为 Generic.xaml  注意大小写,之前遇到因为大小写不对应,导致出错的情况Generic.xam ...

  5. android 自定义空间 组合控件中 TextView 不支持drawableLeft属性

    android 自定义空间 组合控件中 TextView 不支持drawableLeft属性.会报错Caused by: android.view.InflateException: Binary X ...

  6. PHP入门及服务环境配置(Nginx+PHP)

    PHP入门及服务环境配置(Nginx+PHP) PHP入门 PHP维基百科: PHP(全称:PHP:Hypertext Preprocessor,即"PHP:超文本预处理器")是一 ...

  7. 3D特征:关于HFM和HBB

    1.HBB    三维绑定框 (1): 要用到HBB,定义还不太清楚,来自于 VALVE Developer Community (https://developer.valvesoftware.co ...

  8. Oracle 11g XE 与 Oracle SQL Developer 的配置与使用(重制版)

    Oracle 11g XE 与 Oracle SQL Developer 的配置与使用(重制版) 前提概要 项目上需求要适应Oracle数据库,当然这和某EF框架也有关. 因为Oracle 的表名和列 ...

  9. 优动漫PAINT是什么?有哪些功能和特色

    优动漫PAINT软件介绍: 优动漫PAINT是一款功能强大的漫画制作软件,该软件可以帮助漫画创作人员制作出完美,惟妙惟肖的漫画作品,它搭载了绘制漫画和插画所需的所有功能--丰富的笔工具.超强的笔压感应 ...

  10. 浅谈[^>]在正则中的2种用法

    /^A/会匹配"An e"中的A,但是不会匹配"ab A"中的A,此时^A的意思是“匹配开头的A” /[^a-z\s]/会匹配"my 3 sister ...