POJ 1631
#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的更多相关文章
- OpenJudge/Poj 1631 Bridging signals
1.链接地址: http://poj.org/problem?id=1631 http://bailian.openjudge.cn/practice/1631 2.题目: Bridging sign ...
- poj 1631 LIS
题目链接:http://poj.org/problem?id=1631 #include <cstdio> #include <cstring> #include <io ...
- POJ 1631 Bridging signals & 2533 Longest Ordered Subsequence
两个都是最长上升子序列,所以就放一起了 1631 因为长度为40000,所以要用O(nlogn)的算法,其实就是另用一个数组c来存储当前最长子序列每一位的最小值,然后二分查找当前值在其中的位置:如果当 ...
- POJ 1631 Bridging signals
Bridging signals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9441 Accepted: 5166 ...
- DP:Bridging Signals(POJ 1631)
不能交叉的引脚 (这一题的难度在于读题)题目大意:有一堆引脚(signals),左边一排,右边一排,左边从上到下,对应着连接右边的引脚(所有的引脚都被接上),现在引脚之间的连线有交叉,我们要桥接这些交 ...
- poj 1631 Bridging signals (二分||DP||最长递增子序列)
Bridging signals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9234 Accepted: 5037 ...
- POJ 1631 Bridging signals(LIS O(nlogn)算法)
Bridging signals Description 'Oh no, they've done it again', cries the chief designer at the Waferla ...
- POJ 1631 Bridging signals DP(最长上升子序列)
最近一直在做<挑战程序设计竞赛>的练习题,感觉好多经典的题,都值得记录. 题意:给你t组数据,每组数组有n个数字,求每组的最长上升子序列的长度. 思路:由于n最大为40000,所以n*n的 ...
- POJ 1631 Bridging signals(LIS 二分法 高速方法)
Language: Default Bridging signals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 1076 ...
随机推荐
- HDU1006
Problem Description The three hands of the clock are rotating every second and meeting each other ma ...
- 行转列求和:不加 in 条件,sum的数据会不会准确?
我的习惯写法,担心不加 in 条件 ,统计结果会包含其他的数据 SELECT ZWKMYE_KJND as 年度,ZWKMYE_KJQJ as 月份,ZWKMYE_DWBH as 单位, ' then ...
- JavaScript高级程序设计之数值数组排序
如果数组中全是Nunber类型,则可以按照数值大小排序 , , , , ]; // asc升序函数 function compareAsc(value1, value2) { if (value1 & ...
- 贵州大学iPhone、Android(安卓)项目助跑计划!!!
该计划旨在帮助同学们将各种脑中稀奇古怪的想法借助互联网/移动互联网相关的技术变成真实的项目. 谱写你的故事,从此刻开始! 我们帮助你提高编程(Java.C++.Objective-C.Android. ...
- 教你怎么安装RabbitMQ
以下命令以root用户运行:#echo 'deb http://www.rabbitmq.com/debian/ testing main' >> /etc/apt/sources.lis ...
- Django+Nginx+MongoDB+Mysql+uWsgi的搭建
搭建目标如下: 图:系统架构图 这个系统可以提供web服务及其它查询应用服务,我用其做一个二手房信息搜集.处理及分发的系统,可以通过浏览器访问,也可以通过定制的客户端进行访问. 一.安装篇 1.下载安 ...
- UITextField的常用属性,Delegate,重绘
一 属性 UITextField * myTextField = [[UITextField alloc] initWithFrame:CGRectMake(50, 100, 200, 50 ...
- [超简洁]EasyQ框架-应对WEB高并发业务(秒杀、抽奖)等业务
背景介绍 这几年一直在摸索一种框架,足够简单,又能应付很多高并发高性能的需求.研究过一些框架思想如DDD DCI,也实践过CQRS框架. 但是总觉得复杂度高,门槛也高,自己学都吃力,如果团队新人更难接 ...
- 硬件描述语言Verilog设计经验总结
一.硬件描述语言Verilog 粗略地看Verilog与C语言有许多相似之处.分号用于结束每个语句,注释符也是相同的(/* ... */和// 都是熟悉的),运算符"=="也用来测 ...
- urllib3 ConnectionPools
A connection pool is a container for a collection of connections to a specific host.If you need to m ...