adas
张家睿
·
·
个人记录
#include<iostream>
#include<stack>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1000000;
int d[maxn];
int f[maxn];
int erfen(int x,int s)
{
int mid,l,r;
for(l=1,r=x+1;l<=r;)
{
mid=(r+l)/2;
if(s>f[mid])
l=mid+1;
else
r=mid-1;
}
return l;
}
int main()
{
int a[maxn],o=0;
memset(d,0x3f,sizeof(d));
while(cin>>a[++o])
for(int i=1;i<=o;i++)
{
f[erfen(o,a[i])]=a[i];
}
int k=o+1;
a[k]=maxn;
int ans=0;
for(int i=1;i<=o;i++)
if(f[i]<a[k])
ans++;
cout<<ans;
return 0;
}