ZOJ 2136 Longest Ordered Subsequence

 #include<time.h>
#include <cstdio>
#include <iostream>
#include<algorithm>
#include<math.h>
#include <string.h>
#include<vector>
#include<queue>
using namespace std; int d[],a[];
int len,i,k,n,m; int binary(int t)
{
int low,high,mid;
low=;
high=len;
while(low<high)
{
       //mid=low+(high-low)*(num-p[low])/(p[high]-p[low]);//插值排序
mid=(low+high)/;
if(d[mid]<=t)
low=mid+;
else
high=mid;
}
return low;
} int main()
{
int cas;
cin>>cas;
while(cas--)
{
cin>>n;
for(i=;i<=n;i++)
cin>>a[i];
len=;
d[]=-;
for(i=;i<=n;i++)
{
if(a[i]>d[len])
{
len++;
d[len]=a[i];
//cout<<d[len]<<" ";
}
else
{
k=binary(a[i]);
d[k]=a[i];
}
}
cout<<len<<endl;
if(cas) //这里是个坑
cout<<endl;
}
return ;
}
上一篇:(转载)FT232RL通信中断问题解决办法总结


下一篇:IMP-00038:无法转换为环境字符集句柄