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 ...
随机推荐
- umilit 修改 linux 最多可打开文件数
ulimit -n 修改 临时修改: ulimit -SHn 65535 永久修改: echo '* - nofile 65535' >> /etc/security/li ...
- Testing shell commands from Python
如何测试shell命令?最近,我遇到了一些情况,我想运行shell命令进行测试,Python称为万能胶水语言,一些自动化测试都可以完成,目前手头的工作都是用python完成的.但是无法从Python中 ...
- 创建自定义JSR303的验证约束(Creating custom constraints)
转载:http://clongjava.iteye.com/blog/1317649 由于输入验证在软件开发中是必须的一件事情,特别是与用户交互的软件产品,验证用户的潜在输入错误是必不可少的一件事情, ...
- MML命令_华为TD-LTE后台常用MML命令操作
MML命令 2013年12月09日 from:https://blog.csdn.net/koudaidai/article/details/17219821 设备 类别 操作 详细 RNC 小区状态 ...
- uname命令行
常用命令uname -v # uname -i #uname -a dream361@master:~$ uname -n #主机名称 master dream361@master:~$ uname ...
- va_start、va_arg、va_end、va_copy 可变参函数
1.应用与原理 在C语言中,有时我们无法给出一个函数参数的列表,比如: int printf(const char *format, ...); int fprintf(FILE *s ...
- 评价指标的计算:accuracy、precision、recall、F1-score等
记正样本为P,负样本为N,下表比较完整地总结了准确率accuracy.精度precision.召回率recall.F1-score等评价指标的计算方式: (右键点击在新页面打开,可查看清晰图像) 简单 ...
- 软件包 com.baidu.location
http://developer.baidu.com/map/loc_refer/index.html?com/baidu/location/package-summary.html
- CentOS 6.5 部署 Horizon
以root用户进行部署,python源也可以使用 http://mirrors.aliyun.com/pypi/simple/ 修改系统 更改SElinux的配置文件 /etc/selinux/con ...
- 隐居网V2.0
经过一个月加班加点的努力,我们终于把隐居网V2.0版做好了(一个设计两个前端三个程序).上一版的隐居网因为经验不够底层架构没搭好(前台和后台都是),又是赶工期,导致后面越做越坑爹.所谓从哪里跌倒从哪里 ...