博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
bzoj1046 [HAOI2007]上升序列
阅读量:4344 次
发布时间:2019-06-07

本文共 800 字,大约阅读时间需要 2 分钟。

二分优化LIS

字典序最小的方案不好求。

于是就倒过来求以一个数开头的最长上升子序列。

字典序小的放前面。

输出时取最优就好。

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 using namespace std;13 const int INF=2147483647;14 int n,f[10010],a[10010],stack[10010],top,temp,m,x;15 int main()16 {17 scanf("%d",&n);18 memset(stack,128,sizeof(stack));19 stack[top]=INF;20 for(int i=1;i<=n;i++)scanf("%d",&a[i]);21 for(int i=n;i>=1;i--)22 {23 int l=0,r=top,ans=0;24 while (l<=r)25 {26 int m=(l+r)>>1;27 if (a[i]
top)cout<<"Impossible\n";38 else if(!x)cout<<"\n";39 else for(int i=1,t=-INF;i<=n;i++) 40 if(f[i]>=x&&t

 

转载于:https://www.cnblogs.com/HugeGun/p/5151294.html

你可能感兴趣的文章
MySQL 处理重复数据
查看>>
关于typedef的用法总结(转)
查看>>
【strtok()】——分割字符串
查看>>
Linux下安装rabbitmq
查看>>
曹德旺
查看>>
【转】判断点在多边形内(matlab)
查看>>
java基础之集合:List Set Map的概述以及使用场景
查看>>
Python 线程 进程 协程
查看>>
iOS语言中的KVO机制
查看>>
excel第一次打开报错 向程序发送命令时出错 多种解决办法含终极解决方法
查看>>
响应式web设计之CSS3 Media Queries
查看>>
实验三
查看>>
机器码和字节码
查看>>
环形菜单的实现
查看>>
【解决Chrome浏览器和IE浏览器上传附件兼容的问题 -- Chrome关闭flash后,uploadify插件不可用的解决办法】...
查看>>
34 帧动画
查看>>
二次剩余及欧拉准则
查看>>
thymeleaf 自定义标签
查看>>
关于WordCount的作业
查看>>
UIView的layoutSubviews,initWithFrame,initWithCoder方法
查看>>