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 ...
随机推荐
- logback配置日志输出
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> & ...
- Qt5.3中qml ApplicationWindow设置窗口无边框问题
这个版本的qt在这里有点bug.. 设置ApplicationWindow的flags属性为Qt.FramelessWindowHint的确可以使程序无边框,但是同时程序在任务栏的图标也没了. 看文档 ...
- Math Issues
Oh no, our Math object was "accidently" reset. Can you re-implement some of those function ...
- (转)让IE6/IE7/IE8浏览器支持CSS3属性
原文链接 http://blog.csdn.net/h5_queenstyle12/article/details/50437442 一.下载 搜索下载:ie-css3.htc,它是让IE浏览器支持C ...
- HDU 5875 Function (线段树+gcd / 单调栈)
题意:给你一串数a再给你一些区间(lef,rig),求出a[lef]%a[lef+1]...%a[rig] 题解:我们可以发现数字a对数字b取模时:如果a<b,则等于原数,否则a会变小至少一半. ...
- nodejs编译sass模块包 node-compass,与gulp包gulp-sass使用方法
简介:node express或者就是node项目中,要自动编译sass方法很多,比如gulp 比如考拉,比如今天我想说的这个包node-compass. 编译sass的三种方法: 前提条件: 都需要 ...
- C++实现设计模式之 —策略与简单工程结合
策略模式封装算法 // cash.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> #inc ...
- Map以及其子类
package com.Map; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; i ...
- 多网卡下,vlc发送IGMP组播报告包
这两天测试IGMP遇到一个问题,环境描述如下: 我的vlc客户端安装在windows下,该PC有两张网卡,本地连接1接公司网,本地链接2 接路由器.wireshark坚挺本地链接2,以测试路由的IGM ...
- ubuntu16 sogou install
1,下载搜狗deb文件(ubuntu16不要参考搜狗旧的安装文档): http://pinyin.sogou.com/linux/ 2,双击sogoupinyin_2.1.0.0086_amd64.d ...