题目链接:

http://www.codeforces.com/contest/446/problem/A

题解:

dp1[x]表示以x结尾的最大严格升序连续串,dp2[x]表示以x开头的最大严格升序连续串

#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<list>
#include<stack>
#include<algorithm>
using namespace std; const int maxn = + ;
const int INF = 2e9;
typedef __int64 LL; int n;
int dp1[maxn], dp2[maxn];
int arr[maxn]; void init() {
memset(dp1, , sizeof(dp1));
memset(dp2, , sizeof(dp2));
} int main() {
while (scanf("%d", &n) == && n) {
init();
for (int i = ; i < n; i++) scanf("%d", arr + i);
dp1[] = ;
for (int i = ; i < n; i++) {
if (arr[i] > arr[i - ]) dp1[i] = dp1[i - ] + ;
else dp1[i] = ;
}
dp2[n - ] = ;
for (int i = n - ; i >= ; i--) {
if (arr[i] < arr[i + ]) dp2[i] = dp2[i + ] + ;
else dp2[i] = ;
}
int ans = max(dp2[] + , dp1[n - ]+);
for (int i = ; i < n - ; i++) {
if (arr[i - ] < arr[i + ] - ) ans = max(ans, dp1[i - ] + + dp2[i + ]);
else {
ans = max(ans,dp1[i - ] + );
ans = max(ans,dp2[i + ] + );
}
}
printf("%d\n", ans);
}
return ;
}

Codeforces Round #FF (Div. 1) A. DZY Loves Sequences的更多相关文章

  1. DP Codeforces Round #FF (Div. 1) A. DZY Loves Sequences

    题目传送门 /* DP:先用l,r数组记录前缀后缀上升长度,最大值会在三种情况中产生: 1. a[i-1] + 1 < a[i+1],可以改a[i],那么值为l[i-1] + r[i+1] + ...

  2. Codeforces Round #FF (Div. 1) A. DZY Loves Sequences 动态规划

    A. DZY Loves Sequences 题目连接: http://www.codeforces.com/contest/446/problem/A Description DZY has a s ...

  3. Codeforces Round #FF (Div. 2) C. DZY Loves Sequences

    解题报告:输入一个数列,选取一个子数列,要求最多只能改动这个子数列中的一个数,使得这个子数列是严格的升序的(严格升序没有相等的) 我的做法是,第一步把这个 数列的每个升序的子数列都找出来,然后看这些子 ...

  4. Codeforces Round #FF (Div. 1) B. DZY Loves Modification 优先队列

    B. DZY Loves Modification 题目连接: http://www.codeforces.com/contest/446/problem/B Description As we kn ...

  5. Codeforces Round #FF (Div. 2) D. DZY Loves Modification 优先队列

    D. DZY Loves Modification time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  6. Codeforces Round #FF (Div. 1) B. DZY Loves Modification

    枚举行取了多少次,如行取了i次,列就取了k-i次,假设行列单独贪心考虑然后相加,那么有i*(k-i)个交点是多出来的:dpr[i]+dpc[k-i]-i*(k-i)*p 枚举i取最大值.... B. ...

  7. Codeforces Round #FF (Div. 2):B. DZY Loves Strings

    B. DZY Loves Strings time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #FF (Div. 2)__E. DZY Loves Fibonacci Numbers (CF447) 线段树

    http://codeforces.com/contest/447/problem/E 题意: 给定一个数组, m次操作, 1 l r 表示区间修改, 每次 a[i] +  Fibonacci[i-l ...

  9. Codeforces Round #FF (Div. 2) A. DZY Loves Hash

    DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the ...

随机推荐

  1. 利用jQuery获取鼠标当前的坐标

    文字来源:http://www.smalluv.com/jquery_code_106.html jQuery获取当前鼠标坐标位置: <div id="testDiv"> ...

  2. OpenFileDialog使用方法

    OpenFileDialog基本属性 AddExtension 控制是否将扩展名自动添加到文件名上 CheckFileExists 指示用户指定不存在的文件时是否显示警告 CheckPathExist ...

  3. text-rendering 详解

    原文链接:http://www.feeldesignstudio.com/2013/05/text-rendering Text-rendering 属性是一个非标准属性,主要用来告诉渲染引擎(ren ...

  4. 图片来自腾讯,未经授权不可引用,js解决方法

    问题记录,解决后来更新 js伪造Referer, 外链图片让用户浏览时,不发送 referer 字段给原网站的方法 A 网站引用了 B 站的 图片 <img src="b_url&qu ...

  5. dede 单表模型动态浏览设置 arclistsg arc.sglistview.class.php

    比如,分类信息,内容页默认都是生成静态的,如果有需要设为动态访问的,可以参考如下方法: arclistsg 标签,单表独立模型的文档列表调用标记 方法一: 在arclist标签使用中,其对应主表ded ...

  6. struts2集成javamail发邮件(带附件)实践记录

    一.代码预览 这两天在做struts2上的邮件发送.以前的项目有用到spring,用spring提供的邮件支持类很方便可以完成这个功能,但是现在只用struts2的话,就碰到了一系列的问题. 代码是从 ...

  7. DevExpress控件使用经验总结- GridView列表行号显示操作

    DevExpress是一个比较有名的界面控件套件,提供了一系列的界面控件套件的DotNet界面控件.本文主要介绍我在使用DevExpress控件过程中,遇到或者发现的一些问题解决方案,或者也可以所示一 ...

  8. C# 判断是否为闰年的条件各是

    //try 没增加异常数据处理 Console.WriteLine("根据输入的信息计算当年某个月份的天数,以及当年是否是闰年或平年,\n并判断2月份特殊月份的天数."); Con ...

  9. C# 平时碰见的问题【4】

    1. 模糊查询 like的参数化写法 string keyword="value"; // 要模糊匹配的值 错误示范:   sql:    string strSql=" ...

  10. windows下文件名非法字符

    / \ : * ? " < > | / \如果用作文件名,会产生路径问题.因为绝对路径用 \ ; 相对路径用  / ;