Codeforces Round #205 (Div. 2)C 选取数列可以选择的数使总数最大——dp
http://codeforces.com/contest/353/problem/C
Codeforces Round #205 (Div. 2)C
#include<stdio.h> int s[];
int dp[];
char str[];
int Max(int a,int b){
if(a<b)return b;
else return a;
}
int main(){
int n;
while(scanf("%d",&n)!=EOF){
int i;
dp[]=;
for(i=;i<=n;i++){
scanf("%d",&s[i]);
dp[i]=dp[i-]+s[i];
} scanf("%s",str);
int all=,max=;
for(i=n-;i>=;i--){
if(str[i]=='')continue;
max=Max(max,all+dp[i]);
all+=s[i+];
}
max=Max(all,max);
printf("%d\n",max);
} return ;
}
Codeforces Round #205 (Div. 2)C 选取数列可以选择的数使总数最大——dp的更多相关文章
- Codeforces Round #205 (Div. 2)
A #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> ...
- Codeforces Round #205 (Div. 2) : D
思维题,感叹自己的智商不够啊. 思路大概是这样的: 1.排在队伍前面的女生是不用换位置的: 2.女生在队伍中的顺序是不会变的: 3.最后一个女生稳定了则程序结束: 4.每个女生都有个初始位置和最终位置 ...
- Codeforces Round #205 (Div. 2) : C
感觉像是一个数位dp,高位的1如果不选的话,前面低位的数都可以选:不然只能选择为1的数: 代码: #include<iostream> #include<algorithm> ...
- Codeforces Round #205 (Div. 2) : B
如果某个数出现的次数大于或等于2次,那么平均分配到两个容器里面: 这里利用一个k来使得当出现次数为奇数时候分配得更加均匀: 剩下的就平均分配到两个容器里: 代码: #include<iostre ...
- Codeforces Round #205 (Div. 2) : A
题意: 要求找到最少次数的交换次数使得两组数都是偶数: 很明显答案要么是0,要么是1,或者不管怎么交换都不行(-1): 所以: #include<cstdio> #define maxn ...
- Codeforces Round #333 (Div. 1) C. Kleofáš and the n-thlon 树状数组优化dp
C. Kleofáš and the n-thlon Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...
- Codeforces Round #396 (Div. 2) E. Mahmoud and a xor trip 树形压位DP
题目链接:http://codeforces.com/contest/766/problem/E Examples input 3 1 2 3 1 2 2 3 out 10 题意: 给你一棵n个点 ...
- Codeforces Round #568 (Div. 2) G1. Playlist for Polycarp (easy version) (状压dp)
题目:http://codeforces.com/contest/1185/problem/G1 题意:给你n给选项,每个选项有个类型和价值,让你选择一个序列,价值和为m,要求连续的不能有两个相同的类 ...
- Codeforces Round #416(Div. 2)-811A.。。。 811B.。。。 811C.dp。。。不会
CodeForces - 811A A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 meg ...
随机推荐
- ansible入门七(实战)
Ansible实战:部署分布式日志系统 本节内容: 背景 分布式日志系统架构图 创建和使用roles JDK 7 role JDK 8 role Zookeeper role Kafka role ...
- JavaScript---js的模块化
js的模块模式被定义为给类提供私有和公共封装的一种方法,也就是我们常说的“模块化”. 怎么实现“模块化”? 通过闭包的原理来实现“模块化” ,具体实现:1.必须有外部的封闭函数,该函数必须至少被调用 ...
- C++高级编程2. 静态动态链接库
C++高级编程2. 静态动态链接库20131018 1.动态链接库和静态链接库的区别: 静态链接库就是把lib文件中用到的函数代码直接连接进目标程序,程序运行的时候不在需要其他的库文件:动态链接库是把 ...
- confluence 部署与配置
什么是confluence 部署步骤 安装 下载目标平台目标版本安装包.windows为例 若第一次默认安装 一直下一步. 若再次安装 下载并将mysql 连接控件放到 /xxx/xxx/conflu ...
- is7.0中发布mvc网站,一直无法正常执行路由的解决办法
在config中加一句话: <system.webServer> <validation validateIntegratedModeConfiguration="fals ...
- 一台服务器的IIS绑定多个域名
等待十分钟: 在IIS上配置:
- Spring报错:java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
感谢:http://blog.chinaunix.net/uid-20681545-id-184633.html提供的解决方案,非常棒 ! 问题说明: 新建一个Spring项目,新建一个Bean类:H ...
- vue.js 源代码学习笔记 ----- core scedule.js
/* @flow */ import type Watcher from './watcher' import config from '../config' import { callHook } ...
- OGG到OGGAdapter配置详情-从Oracle直接抽取成csv文件
Oracle Golden Gate是Oracle旗下一款支持异构平台之间高级复制技术,是Oracle力推一种HA高可用产品,简称“OGG”,可以实现Active-Active 双业务中心架构 1.1 ...
- Android.mk编译的写法
更多Android.mk的 用法见 :http://blog.csdn.net/fengbingchun/article/details/38705519 如何修改Android.mk 为Androi ...