hdu 1950 Bridging signals 【最长上升子序列】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1950

题目很简单,就是要用nlogn时间复杂度求解该题。

#include<bits/stdc++.h>
#include<string.h> 
using namespace std;
#define INF 0x3f3f3f3f
int dp[40002],a[40002];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		for(int i=0;i<n;i++)
		  cin>>a[i];
		fill(dp,dp+n,INF);
		for(int i=0;i<n;i++)
		  *lower_bound(dp,dp+n,a[i])=a[i];
		cout<<lower_bound(dp,dp+n,INF)-dp<<endl;
	}
	return 0;
 } 

猜你喜欢

转载自blog.csdn.net/LOOKQAQ/article/details/81565325