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 ...
随机推荐
- 【BZOJ】3389: [Usaco2004 Dec]Cleaning Shifts安排值班(贪心)
http://www.lydsy.com/JudgeOnline/problem.php?id=3389 显然左端点排序后,依次取. 要考虑下一次取的方案: 待选点为a[j].x<=a[now] ...
- DataTable RowFilter 过滤数据
用Rowfilter加入过滤条件 eg: string sql = "select Name,Age,Sex from UserInfo"; DataTable dt = Data ...
- CentOS7 修改默认时区为 北京时间
首先同步时间 yum install -y ntpdate ntpdate -u cn.pool.ntp.org 然后设置中国时区(北京时间) timedatectl set-timezone Asi ...
- ant+jmeter+jenkins+git持续集成以及邮件报告展示
前序准备工作: ant--下载地址:http://ant.apache.org/bindownload.cgi jmeter--下载地址:http://jmeter.apache.org/downlo ...
- 20165202 2017-2018-2 《Java程序设计》第7周学习总结
20165202 2017-2018-2 <Java程序设计>第7周学习总结 教材学习内容总结 Ch11 连接MySQL数据库 下载JDBC-MySQL数据库驱动 加载JDBC-MySQL ...
- AS3帮助手册
http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/index.html
- Myeclipse WEB工程JSP使用JNDI 数据库连接池连接Mysql数据库
在网上查了很多,最后实现了.下面写一下过程: 首先,在WEBROOT/META-INF下建一个文件context.xml,内容为: <?xml version="1.0" e ...
- 现代前端技术解析:Web前端技术基础
最近几年,越来越多的人投入到前端大军中:时至至今,前端工程师的数量仍然不能满足企业的发展需求:与此同时,互联网应用场景的复杂化提高了对前端工程师能力的要求,一部分初期前端工程师并不能胜任企业的工作 ...
- 删除rz上传失败乱码的文件
[摘要:经过rz上传文件失利时,会发生巨细为0的治码的文件,以下 ls-l -rw-rr1rootroot4703112-1513:48???.htm 这类范例的文件可用以下敕令 find.-maxd ...
- swift实现label换行
so easy 换行的实质为在字符串中添加"\n" so, understand???