#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;
int L[10];
int Length = -1;
int N;
int num;
int BinFind(int Len[], int &X) //返回第一个比X大的下标
{
int L = 0;
int R = Length;
while(L <= R)
{
int Mid = (L+R)/2;
if(X < Len[Mid])
R = Mid - 1;
else if(X > Len[Mid])
L = Mid + 1;
else
return Mid;
}
return L;
}
int main(int argc, char *argv[])
{
freopen("G:\\data.txt", "r", stdin);
cin >> N;
for(int i = 0; i < N; i++)
{
cin >> num;
int cc = BinFind(L, num);
if(cc > Length)
L[++Length] = num;
else
L[cc] = num;
}
cout << Length << endl;
return 0;
}
二分求LIS
猜你喜欢
转载自blog.csdn.net/canhelove/article/details/88390643
今日推荐
周排行