Codeforces Round #FF (Div. 2):B. DZY Loves Strings
1 second
256 megabytes
standard input
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?
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.
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
41
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的更多相关文章
- 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] + ...
- Codeforces Round #254 (Div. 1) D - DZY Loves Strings
D - DZY Loves Strings 思路:感觉这种把询问按大小分成两类解决的问题都很不好想.. https://codeforces.com/blog/entry/12959 题解说得很清楚啦 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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. ...
- Codeforces Round #FF (Div. 1) A. DZY Loves Sequences
题目链接: http://www.codeforces.com/contest/446/problem/A 题解: dp1[x]表示以x结尾的最大严格升序连续串,dp2[x]表示以x开头的最大严格升序 ...
- 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 ...
随机推荐
- [JavaEE] 了解Java连接池
转载自51CTO http://developer.51cto.com/art/201006/207768.htm 51CTO曾经为我们简单的介绍过Java连接池.要了解Java连接池我们先要了解数据 ...
- GStreamer基础教程01 - Hello World
摘要 在面对一个新的软件库时,第一步通常实现一个“hello world”程序,来了解库的用法.对于GStreamer,我们可以实现一个极简的播放器,来了解GStreamer的使用. 环境配置 为了快 ...
- WebDav协议基于HTTP 1
首先第一篇提供配置WebDav的方式 网上找了两篇比较好的配置方式分别适用于Win7 Win2003,而且都经过测试配置可以正常使用 原文中保留了引用地址,这个纯属为了要尊重别人的劳动成果 在第二篇中 ...
- Aspose.cell中的Excel模板导出数据
//Excel模板导数据(Eexcel中根据DataTable中的个数,给多个Sheet中的模板赋值) public void DataSetToManyExcel(string fileName, ...
- .net几种文件下载的方法
.Net文件下载方式.... 之前在写上传文件.下载文件的时候,发现Response对象里面有好几种下载文件的方式,之后自己亲自实践了这几种方法,记录下以便以后复习... WriteFile文件下载 ...
- VCRuntime静默安装
批处理脚本: "%~dp0\VC_X64Runtime\VC_x64Runtime.exe" /q"%~dp0\VC_X86Runtime\VC_X86Runtime.e ...
- Android之MVP架构
MVP(Model View Presenter)模式是由MVC模式发展而来的,在如今的Android程序开发中显得越来越重要.本篇文章简单讨论了MVP模式的思想. 啥是MVP MVP模式的主要思想是 ...
- 第5章分布式系统模式 Data Transfer Object(数据传输对象)
正在设计一个分布式应用程序,为了满足单个客户端请求,您发现自己对一个远程接口发出了多个调用,而这些调用所增加的响应时间超出了可接受的程度. 影响因素 在与远程对象通信时,请考虑下列需要权衡的因素: 远 ...
- XML 之 命名空间详解
最近学xml 遇到了点小问题qaq 找了n多的博客大佬,反复看了半小时终于明白了,可能我太蠢了... 基础的知识就不赘述,直接放“栗子”,切重点: <?xml version="1.0 ...
- params可变参数、SqlCommand.Parameters.add()方法
namespace params可变参数{ class Program { static void Main(string[] args) { int[] num = {66,99,55,44, }; ...