codevs1044
来源:互联网 发布:路由器js注入 编辑:程序博客网 时间:2024/05/07 19:06
题目地址:http://codevs.cn/problem/1044/
分析:
贪心+动归
代码:
Var h,sum:array [1..20] of longint; n:longint;Procedure input; begin n:=0; while not eoln do begin inc(n); read(h[n]); sum[n]:=1; end; end;Procedure more; var i,j:longint; max:longint; begin for i:=n-1 downto 1 do begin max:=0; for j:=i+1 to n do if(h[j]<=h[i]) and (sum[j]>max) then max:=sum[j]; sum[i]:=max+1; end; max:=0; for i:=1 to n do if sum[i]>max then max:=sum[i]; writeln(max); end;Procedure less; var hh:array [1..20] of longint; i,j,k,p:longint; begin hh[1]:=h[1];k:=1; for i:=2 to n do begin p:=0; for j:=1 to k do if hh[j]>h[i] then if p=0 then p:=j else if hh[j]<hh[p] then p:=j; if p=0 then begin inc(k); hh[k]:=h[i]; end else hh[p]:=h[i]; end; writeln(k); end;Begin input; more; less;End.
0 0
- codevs1044
- [codevs1044] 拦截导弹
- codevs1044拦截导弹
- [codevs4888零件分组][codevs1044拦截导弹]
- codevs1044 拦截导弹(最长不下降子序列dp)
- 【日常学习】【线性DP】codevs1044 拦截导弹题解
- 洛谷P1020/CODEVS1044 导弹拦截(拦截导弹)
- 使用原始套接字编程实现简单的ping程序
- 面向对象的三大特点
- RTTI(运行时类型识别)
- 获取cms指纹
- hdu 1151 最小路径覆盖
- codevs1044
- poj 2059 单调栈
- DbVisualizer 使用方法 图解(可以连接多种数据库的客户端)
- eclipse 直接生成jni头文件
- 非常不错的点餐系统应用ios源码完整版
- 【Web前端】清除浮动&css中文字体
- 驼峰字符串删除
- 32位和64位系统区别及int字节数
- mysql 字符串包含