POJ 1836(双向LIS)
来源:互联网 发布:公司大数据 编辑:程序博客网 时间:2024/05/21 18:31
双向LIS……居然数组又开小了……
Program P1836;var n,i,j,ans:longint; a:array[1..1000] of double; ll,lr:array[1..1000] of longint;function min(a,b:longint):longint;begin if a<b then exit(a) else exit(b);end;begin fillchar(ll,sizeof(ll),0); fillchar(lr,sizeof(lr),0); read(n); for i:=1 to n do read(a[i]); ll[1]:=1; for i:=2 to n do begin for j:=1 to i-1 do if a[j]<a[i] then if (ll[j]>=ll[i]) then ll[i]:=ll[j]+1; if ll[i]=0 then inc(ll[i]); end; lr[n]:=1; for i:=n-1 downto 1 do begin for j:=i+1 to n do if a[j]<a[i] then if (lr[j]>=lr[i]) then lr[i]:=lr[j]+1; if lr[i]=0 then inc(lr[i]); end; ans:=n; for i:=1 to n do ans:=min(ans,n-(ll[i]+lr[i]-1)); for i:=1 to n do for j:=i+1 to n do ans:=min(ans,n-(ll[i]+lr[j])); writeln(ans);end.
- POJ 1836(双向LIS)
- POJ 1836 Alignment 双向LIS+DP
- poj-1836-士兵出列问题-双向LIS
- POJ 1836 Alignment 枚举中间点双向求LIS
- POJ-1836-Alignment-双向LIS-注意double精度
- POJ 1836 LIS拓展
- POJ 1836 Alignment( LIS )
- poj 1836 dp lis
- POJ 1836 Alignment (LIS)
- POJ 1836 Alignment DP(LIS)
- POJ 1836--Alignment(LIS,LCS)
- poj 1836 Alignment (DP LIS)
- POJ 1836 Alignment(LIS)
- POJ 1836 Alignment(DP LIS)
- [POJ 1836]Alignment[DP][LIS]
- Poj 1836 Alignment (双重LIS)
- POJ 1836 Alignment DP LIS
- 2529: Chorus (lis双向)
- 我要学ASP.NET MVC 3.0(十): MVC 3.0 使用 Forms身份验证
- windows后台服务程序范例
- awk正则匹配列中指定的字符
- java 计算PMT公式
- Oracle to_date
- POJ 1836(双向LIS)
- 【C++】拷贝构造函数与赋值操作符的本质性区别分析
- 使用CASE WHEN进行字符串替换处理
- windows下搭建cocos2dx Android开发环境
- 画椭圆 - HTML5 Canvas 作图
- 拷贝构造函数的疑问
- 设计模式之简单工厂模式
- WSAEventSelect
- jquery中ajax方法使用json需注意的小问题