#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int tmp[];
int x[];
int dp[];
char c[];
int main()
{
int i,n;
while(scanf("%d",&n)!=EOF)
{
memset(tmp,,sizeof(tmp));
memset(x,,sizeof(x));
memset(dp,,sizeof(dp));
memset(c,,sizeof(c));
for(i=;i<n;i++)
scanf("%d",&x[i]);
//tmp[i]+=tmp[i]
getchar();
scanf("%s",c);
tmp[]=x[];
for(i=;i<n;i++)
tmp[i]=tmp[i-]+x[i]; if(c[]=='')
dp[]=;
else
dp[]=x[];
for(i=;i<n;i++)
{
if(c[i]=='')
dp[i]=dp[i-];
else
dp[i]=max(dp[i-]+x[i],tmp[i-]);
}
printf("%d\n",dp[n-]);
}
return ;
}

CF 353C Find Maximum #205 (Div. 2)的更多相关文章

  1. Codeforces Round #205 (Div. 2)C 选取数列可以选择的数使总数最大——dp

    http://codeforces.com/contest/353/problem/C Codeforces Round #205 (Div. 2)C #include<stdio.h> ...

  2. cf 20190307 Codeforces Round #543 (Div. 2, based on Technocup 2019 Final Round)

    B. Mike and Children time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  3. cf#513 B. Maximum Sum of Digits

    B. Maximum Sum of Digits time limit per test 2 seconds memory limit per test 512 megabytes input sta ...

  4. Codeforces Round #205 (Div. 2)

    A #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> ...

  5. Codeforces Round #205 (Div. 2) : D

    思维题,感叹自己的智商不够啊. 思路大概是这样的: 1.排在队伍前面的女生是不用换位置的: 2.女生在队伍中的顺序是不会变的: 3.最后一个女生稳定了则程序结束: 4.每个女生都有个初始位置和最终位置 ...

  6. Codeforces Round #205 (Div. 2) : C

    感觉像是一个数位dp,高位的1如果不选的话,前面低位的数都可以选:不然只能选择为1的数: 代码: #include<iostream> #include<algorithm> ...

  7. Codeforces Round #205 (Div. 2) : B

    如果某个数出现的次数大于或等于2次,那么平均分配到两个容器里面: 这里利用一个k来使得当出现次数为奇数时候分配得更加均匀: 剩下的就平均分配到两个容器里: 代码: #include<iostre ...

  8. Codeforces Round #205 (Div. 2) : A

    题意: 要求找到最少次数的交换次数使得两组数都是偶数: 很明显答案要么是0,要么是1,或者不管怎么交换都不行(-1): 所以: #include<cstdio> #define maxn ...

  9. cf C. Find Maximum

    http://codeforces.com/contest/353/problem/C 先预处理前i个数的和,然后找到第一个出现的1,然后变成0后的和与目前的和比较,如果大就更新. #include ...

随机推荐

  1. Eclipse 运行多个Tomcat实例

             

  2. 万能的SQLHelper帮助类

    /// <summary> /// 数据库帮助类 /// </summary> public class SQLHelper { private static string c ...

  3. Linux大量TIME_WAIT的解决办法

    发布:theboy   来源:net   [大 中 小] 根据TCP协议定义的3次握手断开连接规定,发起socket主动关闭的一方 socket将进入TIME_WAIT状态,TIME_WAIT状态将持 ...

  4. 使用cookie解决微信不能存储localStorage的问题

    最近在开发基于微信的Web页面时,发现有些机型不能存储信息到localStorage中,或者是页面一旦关闭,存储的信息也失效了. 于是想到用cookie来替代localStorage,存储一些简单的数 ...

  5. jdbc连接数据库使用sid和service_name的区别

    问题描述: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor The Connect ...

  6. Java 包(package)详解

    为了更好地组织类,Java提供了包机制,用于区别类名的命名空间. 包的作用 1 把功能相似或相关的类或接口组织在同一个包中,方便类的查找和使用. 2 如同文件夹一样,包也采用了树形目录的存储方式.同一 ...

  7. Windows Phone中的图形渲染处理

    前言    这篇文章主要介绍Windows Phone中XAML的渲染处理过程,你可以根据下文中所提到的内容来优化现有的XAML页面,来提高页面渲染的性能. XAML的渲染包括以下两个阶段: 1. 光 ...

  8. pthread属性设置

    Posix线程中的线程属性pthread_attr_t主要包括scope属性.detach属性.堆栈地址.堆栈大小.优先级.在pthread_create中,把第二个参数设置为NULL的话,将采用默认 ...

  9. How to: Add SharePoint 2010 Search Web Parts to Web Part Gallery for Upgraded Site Collections

    When you upgrade to Microsoft SharePoint Server 2010, some of the new SharePoint Enterprise Search W ...

  10. C#错误:The Controls collection cannot be modified

    用 <%# %>这种写法是写在数据绑定控件中的,之所以用 <%= %>会出现The Controls collection cannot be modified because ...