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 ...
随机推荐
- [BZOJ 2100] Apple Delivery
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2100 [算法] Answer = min{ dist(PB,PA1) + dist( ...
- 网络:万维网(WWW)
ylbtech-网络:万维网(WWW) www (万维网缩写)同义词 万维网一般指www(万维网缩写)WWW是环球信息网的缩写,(亦作“Web”.“WWW”.“'W3'”,英文全称为“World Wi ...
- [转载]H3C S3600 DHCP-SERVER 配置【原创】
原文地址:H3C S3600 DHCP-SERVER 配置[原创]作者:旅行者萧 案例要求: 在H3C S3600-28TP-SI 的vlan 里配置DHCP server,使用vlan 里部分网段为 ...
- 彻底弄懂px em rem
国内的设计师大都喜欢用px,而国外的网站大都喜欢用em和rem,那么三者有什么区别,又各自有什么优劣呢? PX特点 1. IE无法调整那些使用px作为单位的字体大小: 2. 国外的大部分网站能够调整的 ...
- PyQt5信号-槽机制
signal -> emit -> slot signal.connect(slot) signal.disconnect(slot) 信号 (singal) 可以连接无数多个槽 (slo ...
- vcpkg错误分析方法
最近在使用vcpkg时,经常会碰到CMake错误. 有些以前能编译通过的包, 过一段时间又不能编译错误了. 错误提示一般是CMake错误, 弄得很郁闷. 我采用以下步骤解决了问题: 分析错误 查看错误 ...
- Django中的session和cookie及分页设置
cookie Cookie的由来 大家都知道HTTP协议是无状态的. 无状态的意思是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接关系,它不会受前面的请求响应情况直接影响,也不 ...
- HDU 3018 一笔画问题
题意:给你一个图 判断最少用几笔把这个图画出来(画过的边不能重新画) 思路: 并查集+欧拉回路 仔细想一想. 在一个强连通分量中 所有度为奇数的点之和÷2就是要画的笔画数 Now question : ...
- Css问题 margin float 文档流 背景图底部充满
今天来整理一下做网页遇到的问题吧 1.插入背景图片并使图片居于div底部充满整个行. <style> background:url(xxx.jpg) no-repeat; backgrou ...
- javascript中天气接口案例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...