CF 353C Find Maximum #205 (Div. 2)
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int tmp[];
int x[];
int dp[];
char c[];
int main()
{
int i,n;
while(scanf("%d",&n)!=EOF)
{
memset(tmp,,sizeof(tmp));
memset(x,,sizeof(x));
memset(dp,,sizeof(dp));
memset(c,,sizeof(c));
for(i=;i<n;i++)
scanf("%d",&x[i]);
//tmp[i]+=tmp[i]
getchar();
scanf("%s",c);
tmp[]=x[];
for(i=;i<n;i++)
tmp[i]=tmp[i-]+x[i]; if(c[]=='')
dp[]=;
else
dp[]=x[];
for(i=;i<n;i++)
{
if(c[i]=='')
dp[i]=dp[i-];
else
dp[i]=max(dp[i-]+x[i],tmp[i-]);
}
printf("%d\n",dp[n-]);
}
return ;
}
CF 353C Find Maximum #205 (Div. 2)的更多相关文章
- Codeforces Round #205 (Div. 2)C 选取数列可以选择的数使总数最大——dp
http://codeforces.com/contest/353/problem/C Codeforces Round #205 (Div. 2)C #include<stdio.h> ...
- cf 20190307 Codeforces Round #543 (Div. 2, based on Technocup 2019 Final Round)
B. Mike and Children time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- cf#513 B. Maximum Sum of Digits
B. Maximum Sum of Digits time limit per test 2 seconds memory limit per test 512 megabytes input sta ...
- 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 ...
- cf C. Find Maximum
http://codeforces.com/contest/353/problem/C 先预处理前i个数的和,然后找到第一个出现的1,然后变成0后的和与目前的和比较,如果大就更新. #include ...
随机推荐
- 【个人】IIS Express 配置
<!-- 查看URL访问控制列表: netsh http show urlacl 添加URL访问控制: netsh http add urlacl url=http://myhostname:8 ...
- 关于Silverlight调用天气预报接口问题
问题:因Silverlight客户端不能直接调用webservice接口(外网天气接口),调用会出现跨域访问的问题,即使添加了跨域文件也不好使.解决方法如下 解决方法一:1.在服务端建立一个wcf服务 ...
- mongodb的常用操作(二)
继续mongodb的学习: 9.mongodb条件查询 假设有user集合,里面结构如下:{ "_id" : ObjectId("52ab35d281181f853264 ...
- mongodb学习之路1
第一节 MongoDB介绍及下载与安装 引言 MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似 json的b ...
- oracle窗口函数中range interval的使用
oracle窗口函数中range interval配合一般用来针对指定时间范围进行统计.其中range表示范围,between...and 表示之前的范围和之后的范围 , CURRENT ROW表示当 ...
- Mysql数据库中的计数器表实时更新
如果某个应用中存在计数器,例如网站的总访问量.用户的粉丝数.文件下载数等等.如果相关应用在Mysql数据库的表中保存计数器,在更新计数器的时候可能会碰到并发问题.例如在web应用中,记录网站的点击次数 ...
- 【采集】php str_replace
<?php function my_str_replace($xmlHttp,$order='asc'){ if($order=='asc'){ return str_replace(array ...
- c++数组-矩阵的转置
#include <iostream> using namespace std; int main(){ ][]={{,,},{,,}}; ][]; ;j<;j++){ ;i< ...
- MVC初学 - The type or namespace name 'DbContext' could not be found
问题: The type or namespace name 'DbContext' could not be found (are you missing a using directive or ...
- (转) java 复制文件,不使用输出流复制,高效率,文件通道的方式复制文件
public static void fileChannelCopy(File s, File t) { FileInputStream fi = null; FileOutputStream fo ...