#include <iostream>
#define MAXN 500005
using namespace std; int T[MAXN]; int binary_search(int * a, int size, int num) ; int main()
{
//freopen("acm.acm","r",stdin);
int i;
int index;
int test;
int num;
int place;
int x;
cin>>test; while(test --)
{
index = ;
cin>>num;
cin>>x;
T[] = x;
for(i = ; i < num; ++ i)
{
cin>>x;
if(x <= T[])
{
T[] = x;
}
else if(x > T[index-])
{
T[index ++] = x;
}
else
{
place = binary_search(T,index,x);
T[place] = x;
}
}
cout<<index<<endl;
}
} int binary_search(int * a, int size, int num)
{
int l = ;
int r = size-; while(l <= r)
{
int mid = (l + r) / ;
if(num > a[mid-] && num <= a[mid] )
return mid;
else if(num < a[mid])
r = mid-;
else
l = mid+;
}
}

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com

POJ 1631的更多相关文章

  1. OpenJudge/Poj 1631 Bridging signals

    1.链接地址: http://poj.org/problem?id=1631 http://bailian.openjudge.cn/practice/1631 2.题目: Bridging sign ...

  2. poj 1631 LIS

    题目链接:http://poj.org/problem?id=1631 #include <cstdio> #include <cstring> #include <io ...

  3. POJ 1631 Bridging signals & 2533 Longest Ordered Subsequence

    两个都是最长上升子序列,所以就放一起了 1631 因为长度为40000,所以要用O(nlogn)的算法,其实就是另用一个数组c来存储当前最长子序列每一位的最小值,然后二分查找当前值在其中的位置:如果当 ...

  4. POJ 1631 Bridging signals

    Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9441   Accepted: 5166 ...

  5. DP:Bridging Signals(POJ 1631)

    不能交叉的引脚 (这一题的难度在于读题)题目大意:有一堆引脚(signals),左边一排,右边一排,左边从上到下,对应着连接右边的引脚(所有的引脚都被接上),现在引脚之间的连线有交叉,我们要桥接这些交 ...

  6. poj 1631 Bridging signals (二分||DP||最长递增子序列)

    Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9234   Accepted: 5037 ...

  7. POJ 1631 Bridging signals(LIS O(nlogn)算法)

    Bridging signals Description 'Oh no, they've done it again', cries the chief designer at the Waferla ...

  8. POJ 1631 Bridging signals DP(最长上升子序列)

    最近一直在做<挑战程序设计竞赛>的练习题,感觉好多经典的题,都值得记录. 题意:给你t组数据,每组数组有n个数字,求每组的最长上升子序列的长度. 思路:由于n最大为40000,所以n*n的 ...

  9. POJ 1631 Bridging signals(LIS 二分法 高速方法)

    Language: Default Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1076 ...

随机推荐

  1. .NET开源工作流RoadFlow-流程设计-保存与发布

    如果流程未设计完时可以先保存,以后再打开接着设计.点击工具栏上的保存按钮即可保存当前流程设计: 如果下次要接着设计,则可以打开该流程继续设计: 如果流程设计完成,可以点击安装按钮来发布流程,流程安装成 ...

  2. [转]ubuntu 14.04 系统设置不见了

    [转]ubuntu 14.04 系统设置不见了 http://blog.sina.com.cn/s/blog_6c9d65a10101i0i7.html 不知道删除什么了,系统设置不见了! 我在终端运 ...

  3. 三,samba

    转载:http://www.cnblogs.com/phinecos/archive/2009/06/06/1497717.html 一. samba的安装: sudo apt-get insall  ...

  4. OC中数组类NSArray的详解,常用属性和方法(一)

    数组是一个有序的集合,OC中的数组只能存储对象类型, 但是对于对象的类型没有限制. 通过下标访问数组元素,下标从0开始. NSA

  5. Gentoo 网络接口配置文件说明

    裁剪的Gentoo系统,仅供公司内部使用! [作为备份档案] 网络接口配置:/etc/conf.d/net #设置静态IPconfig_eth0="192.168.1.x/24" ...

  6. android手机配置hosts文件

    Android设备测试服务器时,可能需要修改 hosts 文件指定域名到对应的 IP 地址.Android 是基于 Linux 的系统,与 Linux 类似,通过 hosts 文件来设置. 在 And ...

  7. 深入分析windows下配置wamp环境各模块的版本兼容性

    版本相关概念说明: ts/nts: thread safety 线程安全 TS refers to multithread capable builds. NTS refers to single t ...

  8. 【CentOs】搭建svn服务器

    参考资料: svn攻略: http://blog.csdn.net/colinchan/article/details/1865154 错误解决:http://hi.baidu.com/anglem/ ...

  9. shell编程之sleep的运用

    #!/bin/bashecho -n "Count:"tput sccount=0;while true;doif [ $count -lt 40 ]then let count+ ...

  10. objc swift 混编

    原链接:http://blog.csdn.net/xuanwenchao/article/details/30226823 在xocde6出来我们大部分代码都是用objective-c写的(部分C/C ...