题目:https://jzoj.net/senior/#main/show/1003

n^2 的话递推就可以啦。

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int const maxn=;
int n,h[maxn],f[maxn],g[maxn],ans;
int main()
{
while()
{
scanf("%d",&n);
if(!n)return ;
memset(f,,sizeof f);
memset(g,,sizeof g);
for(int i=;i<=n;i++)scanf("%d",&h[i]);
f[n]=; g[n]=; ans=;//
for(int i=n;i;i--)
for(int j=i+;j<=n;j++)
{
if(h[j]>h[i])f[i]=max(f[i],g[j]+);
else if(h[j]<h[i])g[i]=max(g[i],f[j]+);
ans=max(ans,g[i]);
}
printf("%d\n",ans);
}
}

最新文章

  1. Linux实战教学笔记06:Linux系统基础优化
  2. BFC深入理解
  3. Nginx+FastCGI运行原理
  4. 1.Android 视图及View绘制分析笔记之setContentView
  5. 2016 Multi-University Training Contest 1
  6. MySQL 第二篇
  7. JWPlayer中字幕文件的配置
  8. java生成随机大数据文件
  9. JavaScript instanceof和typeof的区别
  10. TCPDUMP Command Examples
  11. No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=armv7 armv7s)
  12. Pyinstaller(python打包为exe文件)
  13. JdbcTemplate的一次爬坑记录
  14. arcgis api 3.x for js 入门开发系列六地图分屏对比(附源码下载)
  15. Spring AOP概念理解
  16. 计算属性和监听,computed,watch
  17. C#常用的正则工具类写法
  18. List在遍历中删除t元素
  19. 《Spring1之 第一次站立会议(重发)》
  20. Linux 设置 LD_LIBRARY_PATH

热门文章

  1. 习题练习(视觉slam14讲课后习题)
  2. nginx平滑升级实战
  3. 2019西安多校联训 Day4
  4. LINUX-文件的权限 - 使用 &quot;+&quot; 设置权限,使用 &quot;-&quot; 用于取消
  5. NumPy 学习笔记(四)
  6. Boundary Conditions
  7. 洛谷 2777 [AHOI2016初中组]自行车比赛
  8. Unity常用常找(二)
  9. 2018.5.7每天一题面试题----final, finally, finalize 的区别
  10. nyoj 1112 求次数(map, set)