hdu1025 LIS
来源:互联网 发布:linux元字符 编辑:程序博客网 时间:2024/05/22 01:31
这题一看就知道问题可以转换为求一个最长子序列,但是根本不知道求最长子序列的算法,浪费一个晚上想出来之后发现代码实现确实很简单也很优美~ 1次wa,1次pe,1次ac。顺便弱弱的问一下。。鸟神SphinX同学是如何优化到62ms的??我怎么要109ms?
#include<iostream>
#include<algorithm>#include<vector>
using namespace std;
int a[500050];
int b[500050];
int n,x,y,maxlen,tt;
int main()
{
tt=1;
while(cin>>n)
{
for(int i=1;i<=n;i++)
{
scanf("%d%d",&x,&y);
a[x]=y;
}
b[1]=a[1];
maxlen=1;
for(int i=2;i<=n;i++)
{
if(a[i]>b[maxlen])
{
maxlen++;
b[maxlen]=a[i];
}
else
{
*lower_bound(b+1,b+maxlen+1,a[i])=a[i];
}
}
printf("Case %d:\nMy king, at most %d road",tt++,maxlen);
if(maxlen!=1)
{
printf("s");
}
printf(" can be built.\n\n");
}
return 0;
}
- hdu1025 LIS
- hdu1025 - LIS
- hdu1025 LIS
- 【dp:LIS】hdu1025
- HDU1025 nlogn的LIS
- hdu1025
- HDU1025
- hdu1025
- hdu1025
- hdu1025
- HDU1025
- HDU1025:Constructing Roads In JGShining's Kingdom(LIS)
- hdu1025 Constructing Roads In JGShining's Kingdom (nlogn的LIS)
- HDU1025:Constructing Roads In JGShining's Kingdom(LIS(dp+二分))
- HDU1025 Constructing Roads In JGShining's Kingdom (LIS)
- LIS
- LIS
- LIS
- 给ubuntu虚拟机添加硬盘
- 深度解析Android中字体设置
- 自学java--1(初级内容)
- Linux mount Windows共享后编译出现“Value too large for defined data type”的问题 (zz)
- myEclipse运行缓慢解决方法
- hdu1025 LIS
- sqlite使用小结3
- Annotation(注解)是什么?
- 高并发高负载的大型网站系统架构
- sqlite使用小结4
- DrawIndexedPrimitive函数的详细解释
- NTFS 删除文件的恢复
- 《黑马程序员》 银行业务调度系统
- 12.4.1 自定义查询表达式