JZOJ 1003 [ 东莞市选 2007 ] 拦截导弹 —— 递推
2024-08-31 00:07:09
题目: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);
}
}
最新文章
- Linux实战教学笔记06:Linux系统基础优化
- BFC深入理解
- Nginx+FastCGI运行原理
- 1.Android 视图及View绘制分析笔记之setContentView
- 2016 Multi-University Training Contest 1
- MySQL 第二篇
- JWPlayer中字幕文件的配置
- java生成随机大数据文件
- JavaScript instanceof和typeof的区别
- TCPDUMP Command Examples
- No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=armv7 armv7s)
- Pyinstaller(python打包为exe文件)
- JdbcTemplate的一次爬坑记录
- arcgis api 3.x for js 入门开发系列六地图分屏对比(附源码下载)
- Spring AOP概念理解
- 计算属性和监听,computed,watch
- C#常用的正则工具类写法
- List在遍历中删除t元素
- 《Spring1之 第一次站立会议(重发)》
- Linux 设置 LD_LIBRARY_PATH
热门文章
- 习题练习(视觉slam14讲课后习题)
- nginx平滑升级实战
- 2019西安多校联训 Day4
- LINUX-文件的权限 - 使用 ";+"; 设置权限,使用 ";-"; 用于取消
- NumPy 学习笔记(四)
- Boundary Conditions
- 洛谷 2777 [AHOI2016初中组]自行车比赛
- Unity常用常找(二)
- 2018.5.7每天一题面试题----final, finally, finalize 的区别
- nyoj 1112 求次数(map, set)