题意:http://codeforces.com/problemset/problem/1096/D

思路:参考:https://blog.csdn.net/qq_41289920/article/details/100715683

 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin);
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr
#include <string>
#include <time.h>// srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
//******************
int abss(int a);
int lowbit(int n);
int Del_bit_1(int n);
int maxx(int a,int b);
int minn(int a,int b);
double fabss(double a);
void swapp(int &a,int &b);
clock_t __STRAT,__END;
double __TOTALTIME;
void _MS(){__STRAT=clock();}
void _ME(){__END=clock();__TOTALTIME=(double)(__END-__STRAT)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;}
//***********************
#define rint register int
#define fo(a,b,c) for(rint a=b;a<=c;++a)
#define fr(a,b,c) for(rint a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
typedef long long ll;
const double E=2.718281828;
const double PI=acos(-1.0);
//const ll INF=(1LL<<60);
const int inf=(<<);
const double ESP=1e-;
const int mod=(int)1e9+;
const int N=(int)1e6+; char s[N];
ll dp[N][];
ll a[N]; int main()
{
int n;
sc("%d",&n);
sc("%s",s+);
for(int i=;i<=n;++i)sc("%lld",&a[i]);
for(int i=;i<=n;++i)
{
for(int j=;j<=;++j)dp[i][j]=dp[i-][j];
if(s[i]=='h')dp[i][]+=a[i];
else if(s[i]=='a')dp[i][]=min(dp[i][]+a[i],dp[i-][]);
else if(s[i]=='r')dp[i][]=min(dp[i][]+a[i],dp[i-][]);
else if(s[i]=='d')dp[i][]=min(dp[i][]+a[i],dp[i-][]);
}
pr("%lld\n",dp[n][]);
return ;
} /**************************************************************************************/ int maxx(int a,int b)
{
return a>b?a:b;
} void swapp(int &a,int &b)
{
a^=b^=a^=b;
} int lowbit(int n)
{
return n&(-n);
} int Del_bit_1(int n)
{
return n&(n-);
} int abss(int a)
{
return a>?a:-a;
} double fabss(double a)
{
return a>?a:-a;
} int minn(int a,int b)
{
return a<b?a:b;
}

hard or 9102 字符串DP---Educational Codeforces Round 57 (Rated for Div. 2)的更多相关文章

  1. Educational Codeforces Round 57 (Rated for Div. 2) D dp

    https://codeforces.com/contest/1096/problem/D 题意 给一个串s,删掉一个字符的代价为a[i],问使得s的子串不含"hard"的最小代价 ...

  2. [贪心,dp] Educational Codeforces Round 71 (Rated for Div. 2) C. Gas Pipeline (1207C)

    题目:http://codeforces.com/contest/1207/problem/C   C. Gas Pipeline time limit per test 2 seconds memo ...

  3. Educational Codeforces Round 57 (Rated for Div. 2) ABCDEF题解

    题目总链接:https://codeforces.com/contest/1096 A. Find Divisible 题意: 给出l,r,在[l,r]里面找两个数x,y,使得y%x==0,保证有解. ...

  4. Educational Codeforces Round 57 (Rated for Div. 2)

    我好菜啊. A - Find Divisible 好像没什么可说的. #include<cstdio> #include<cstring> #include<algori ...

  5. Educational Codeforces Round 57 (Rated for Div. 2)D(动态规划)

    #include<bits/stdc++.h>using namespace std;char s[100007];long long a[100007];long long dp[100 ...

  6. Educational Codeforces Round 57 (Rated for Div. 2) C 正多边形 + 枚举

    https://codeforces.com/contest/1096/problem/C 题意 问是否存在一正多边形内三点构成的角度数为ang,若存在输出最小边数 题解 三点构成的角是个圆周角,假设 ...

  7. Educational Codeforces Round 57 (Rated for Div. 2) 前三个题补题

    感慨 最终就做出来一个题,第二题差一点公式想错了,又是一波掉分,不过我相信我一定能爬上去的 A Find Divisible(思维) 上来就T了,后来直接想到了题解的O(1)解法,直接输出左边界和左边 ...

  8. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  9. Educational Codeforces Round 64 (Rated for Div. 2)题解

    Educational Codeforces Round 64 (Rated for Div. 2)题解 题目链接 A. Inscribed Figures 水题,但是坑了很多人.需要注意以下就是正方 ...

  10. Educational Codeforces Round 53 (Rated for Div. 2) (前五题题解)

    这场比赛没有打,后来补了一下,第五题数位dp好不容易才搞出来(我太菜啊). 比赛传送门:http://codeforces.com/contest/1073 A. Diverse Substring ...

随机推荐

  1. 下载eclipse 配置eclipse 新建Java项目 写一个小程序 运行

    为了更好的学习java,我打算下载个eclipse 地址:https://www.eclipse.org/downloads/packages/ 我们需要下载的版本是Eclipse IDE for J ...

  2. 使用ImageProcessor、CodeCarvings.Piczard组件生成缩略图和添加水印

    技术栈: 1.ImageProcessor(专业图像处理,不能合成水印,NetCore中有它的升级版ImageSharp目前是预览包) 2.CodeCarvings.Piczard(缩略图,水印都能搞 ...

  3. 微信打开手机内置浏览器跳转手机默认浏览器打开html网页

    微信上进行的网页宣传.游戏传播.APP下载各类活动很多,但是各位朋友肯定经常会遇到一些特殊需求,网页需要在手机默认浏览器打开而不是微信内置浏览器.这个问题怎么解决呢? 斗在微信营销的浪潮中 解决方案: ...

  4. MyBatis-Plus的一些问题

    图一图二分别是搜索设计师的动态sql,已知这个字段是integer类型.为什么用=号查询的时候会显示查询超时.但是我把sql打印出来的结果直接去执行,时间在一秒是可以出来结果的. 但是用like一个i ...

  5. 安装conda后取消命令行前出现的base,取消每次启动自动激活conda的基础环境, 使用ubuntu 自带的Python环境

    方法一: 退出base环境回到系统自带的环境 conda deactivate 方法二 1,通过将auto_activate_base参数设置为false实现: conda config --set ...

  6. GIT上面有的分支,本地却无法检出,也看不到该分支

    正常情况在gitlib上面可以看到代码里面有develop的分支 然而本地在查看所有分支的时候却报错 #查看所有的分支 git branch -a 这种情况是没有更新远程分支的索引,所以这样是看不到的 ...

  7. go 两个数组取并集

    实际生产中,对不同数组取交集.并集.差集等场景很常用,下面来说下两个数组取差集 直接上代码: //两个集合取并集 package main import "fmt" //思想: / ...

  8. 20175329&20175313&20175318 2019-2020 《信息安全系统设计基础》实验一

    详见 https://www.cnblogs.com/xiannvyeye/p/11792152.html#%E4%B8%80%E5%AE%9E%E9%AA%8C%E5%86%85%E5%AE%B9

  9. cs231n lecture2 image classification

    1.图片分类若采用最近邻法: import numpy as np class NearestNeighbor: def _init_(self): pass def train(self, X, y ...

  10. 控制器Controller

    1)  org.springframework.web.servlet.mvc.ParameterizableViewController 如果请求是/hello.action的请求路径,则直接跳转到 ...