最长上升子串
f[i]=f[I-1]+1(f[I]>f[I-1])
f[I]=1;(f[I]<=f[I-1])
输出max(f(I))
最长上升子序列
f[I]=max(f[I],f[j]+1);

For example:D. Remove One Element http://codeforces.com/contest/1272/problem/D

左边扫一遍,右边扫一遍,然后好用
```c++

include<bits/stdc++.h>

using namespace std;
int Dpl[200010], a[200010], Dpr[200010];
int n;
int main()
{
cin >> n;
for (int i = 1;i <= n;++i)
cin >> a[i];
int ans = 1;
Dpl[1] = Dpr[n] = 1;
for (int i = 2;i <= n;++i)
{
if (a[i] > a[i-1])
Dpl[i] = Dpl[i-1]+1;
else
Dpl[i] = 1;
}
for (int i = n-1;i >= 1;--i)
{
if (a[i] < a[i+1])
Dpr[i] = Dpr[i+1]+1;
else
Dpr[i] = 1;
}
for (int i = 2;i <= n;++i)
{
ans = max(ans, Dpl[i]);
if (a[i] > a[i-2])
ans = max(ans, Dpl[i-2]+Dpr[i]);
}
cout << ans;
return 0;
}

最新文章

  1. C# 5.0 异步编程
  2. ASP.NET Core的配置(4):多样性的配置来源[中篇]
  3. 介绍一种基于gulp对seajs的模块做合并压缩的方式
  4. [Ubuntu] 转载-使用Ubuntu修复grub
  5. 【转】Entity Systems
  6. poj 2528 Mayor&#39;s posters(线段树)
  7. jersey post提交到 ContainerRequestFilter 而HttpServletRequest获取不到数据(转)
  8. node.js常用的几个模块总结
  9. ORA-14400: inserted partition key does not map to any partition
  10. 收集经常使用的.net开源项目
  11. Linux学习笔记(一)----Ubuntu下的apt命令
  12. python 时间段的随机日期输出
  13. BurpSuiteProxy安装使用
  14. 【深入Java虚拟机】一 JVM类加载过程
  15. linux 再多的running也挡不住锁
  16. swift - VC添加手势返回
  17. [Vue warn]: Invalid prop: custom validator check failed for prop &quot;xxx&quot;.问题
  18. 深入理解JAVA虚拟机阅读笔记2——垃圾回收
  19. idea中添加模板。
  20. NYOJ 141 Squares (数学)

热门文章

  1. SpringBoot系列教程web篇之自定义异常处理HandlerExceptionResolver
  2. 【bat】实现数组,for循环取数据
  3. centos7修改主机名的方法
  4. 【转帖】全网最通俗易懂的Kafka入门
  5. JVM性能调优的6大步骤,及关键调优参数详解
  6. 嵌入式02 STM32 实验05 蜂鸣器
  7. spark2.2 从入门到精通全套视频教程(含网盘下载地址)
  8. 实现一个 web 服务器
  9. UOJ424 Count 生成函数、多项式求逆、矩阵快速幂
  10. golang ---cron