感觉像是一个数位dp,高位的1如果不选的话,前面低位的数都可以选;不然只能选择为1的数;

代码:

 #include<iostream>
#include<algorithm>
#define maxn 100005
using namespace std;
char s[maxn];
int sum[maxn],num[maxn],n,ans,all; int main()
{
cin>>n;
for(int i=;i<=n;i++)
cin>>num[i],sum[i]+=sum[i-]+num[i];
cin>>s;
for(int i=n-;i>=;i--)
{
if(s[i]=='')continue;
ans=max(all+sum[i],ans);
all+=num[i+];
}
ans=max(all,ans);
cout<<ans;
return ;
}

Codeforces Round #205 (Div. 2) : C的更多相关文章

  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. Codeforces Round #205 (Div. 2)

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

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

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

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

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

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

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

  6. Codeforces Round 536 (Div. 2) (E)

    layout: post title: Codeforces Round 536 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  7. Codeforces Round #506 (Div. 3) D-F

    Codeforces Round #506 (Div. 3) (中等难度) 自己的做题速度大概只尝试了D题,不过TLE D. Concatenated Multiples 题意 数组a[],长度n,给 ...

  8. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  9. Codeforces Round #579 (Div. 3)

    Codeforces Round #579 (Div. 3) 传送门 A. Circle of Students 这题我是直接把正序.逆序的两种放在数组里面直接判断. Code #include &l ...

随机推荐

  1. [Ionic] Ionic Quickstart for Windows

    1. Install ionic 2. Create ionic app ionic start myApp tabs //create a app cd myApp ionic serve // o ...

  2. UVA - 10239 The Book-shelver&#39;s Problem

    Description Problem D The Book-shelver's Problem Input: standard input Output: standard output Time ...

  3. 标准库function类型的使用

    14.44编写一个简单的桌面计算器使其能处理二元运算. #include<iostream> #include<map> #include<functional> ...

  4. oracle数据库敏感操作前创建还原点

    我们都知道,在vmware虚拟机中有一个拍摄快照的功能,我们可以把系统此时的状态保存下来,一方后面遇到不测事件,也好将系统还原,oracle中也有类似功能. 首先创建一张学生表: 向学生表中插入一条数 ...

  5. Java基础知识强化之IO流笔记22:FileInputStream / FileOutputStream 复制文本文件案例1

    1. 使用字节流FileInputStream / FileOutputStream 复制文本文件案例: 分析: (1)数据源:从哪里来 a.txt   --   读取数据  --  FileInpu ...

  6. JavaScript异步操作

    //伪代码写法,只用来记录结构 function test(){ var dtd=$.Deferred(); if(成功){ dtd.resolve(data1,data2); //传递参数 } el ...

  7. Linux删除文件Argument list too long问题的解决方案

    方法一:使用find find . -name 文件 | xargs rm -f 但文件数量过多,find命令也会出现问题: -bash: /bin/find: Argument list too l ...

  8. HTML5本地化应用开发-HTML5 Web存储详解

    文章不是简单的的Ctrl C与V,而是一个字一个标点符号慢慢写出来的.我认为这才是是对读者的负责,本教程由技术爱好者成笑笑(博客:http://www.chengxiaoxiao.com/)写作完成. ...

  9. thinkphp3.2.x版本中图片上传缩略图的解决方案

    调用方式很简单 get_sc($cover_id,[$width=180,$height=auto,$cut]) @param $cover_id 图片ID___ @param $width 宽度__ ...

  10. jquery 如何给新生成的元素绑定 hover事件?

    $("table tr").live({    mouseenter:    function()    {       //todo    },    mouseleave:   ...