根据题意,把值变换成数的个数,这样就变成了求最长非递减子序列,这里用O(n*log(n))的办法
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N =200005;
const int INF =1e9+5;
ll a;
ll v;
ll t;
vector<ll> num;
//LIS O(n*log(n));
int getLISLength( int length)
{
vector<ll> ivec;
ivec.clear();
for(int i = 0; i < length; ++i)
{
if (ivec.size() == 0 || ivec.back() <= num[i])
ivec.push_back(num[i]);
else
{
int low = upper_bound(ivec.begin(),ivec.end(),num[i])-ivec.begin();
ivec[low] =num[i];
}
}
return ivec.size();
}
int main()
{
// freopen("data.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios_base::sync_with_stdio(false);
num.clear();
while(~scanf("%lld",&t))
{
a = t;
if(t<0)
{
v = 0;
}
else if(t>=10000)
{
v = 5;
a -= 10000;
}
else
{
v = 1;
}
for(int i=0;i<v;i++)
{
num.push_back(a);
}
}
printf("%d\n",getLISLength(num.size()));
return 0;
}