#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. Python数据类型-----数字&字符串

    Python数字类型 int类型表示的范围:-2147483648至2147483648之间,超出这个范围的数字即视为long(长整形) 在Python中不需要事先声明数据类型,它是根据具体的赋值来进 ...

  2. poj 2777 Count Color

    题目连接 http://poj.org/problem?id=2777 Count Color Description Chosen Problem Solving and Program desig ...

  3. 九度oj 1525 子串逆序打印

    原题链接:http://ac.jobdu.com/problem.php?pid=1525 字符串简单题,注意开有结尾有空格的情况否则pe or wa #include<algorithm> ...

  4. core java 5~6(OOP & 高级语言特征)

    MODULE 5 OOP 面向对象程序设计--------------------------------------------------------Object Oriented Program ...

  5. Linux开机启动程序详解

    Linux开机启动程序详解我们假设大家已经熟悉其它操作系统的引导过程,了解硬件的自检引导步骤,就只从Linux操作系统的引导加载程序(对个人电脑而言通常是LILO)开始,介绍Linux开机引导的步骤. ...

  6. iOS七大手势之(平移、捏合、轻扫、屏幕边缘轻扫)手势识别器方法

    使用手势很简单,分为两步: 创建手势实例.当创建手势时,指定一个回调方法,当手势开始,改变.或结束时,回调方法被调用. 添加到需要识别的View中.每个手势只对应一个View,当屏幕触摸在View的边 ...

  7. 编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法

    lib/libQtGui.so: undefined reference to `ts_read_raw' /lib/libQtGui.so: undefined reference to `ts_o ...

  8. iOS 进阶 第十六天(0419)

    0419 任何view默认不支持多点触控,有一个属性设置Multiple Touch,设置为Yes即可支持多点触控 触摸移动一个view,让view也跟着动代码 关于触摸的一些解释: 注意:touch ...

  9. [LAMP]——mod_security和mod_evasive模块的安装

    系统版本:Red Hat 6 httpd版本:httpd-2.4.20 tar包:modsecurity-apache_2.5.9.tar.gz   mod_evasive_1.10.1.tar.gz ...

  10. Oracle数据文件在open状态被删除的恢复记录

    1.查看当前状态: SQL> select status from v$instance; STATUS------------OPEN SQL> show parameter name; ...