标签:序列 ret 变换 ons href org code span -o
#include<bits/stdc++.h>
#define R register int
using namespace std;
const int N=1000001;
int n,Mx,ans,len,O[N],vis[N],f[N],w[N],T[N];
int gi(){
R x=0,k=1;char c=getchar();
while(c!=‘-‘&&(c<‘0‘||c>‘9‘))c=getchar();
if(c==‘-‘)k=-1,c=getchar();
while(c>=‘0‘&&c<=‘9‘)x=(x<<3)+(x<<1)+c-‘0‘,c=getchar();
return x*k;
}
int main(){
n=gi();
for(R i=1;i<=n;++i)w[i]=gi(),O[i]=w[i];
sort(O+1,O+n+1),len=unique(O+1,O+n+1)-O-1;
for(R i=1;i<=n;++i){
w[i]=lower_bound(O+1,O+len+1,w[i])-O;
if(!vis[w[i]])f[i]=T[w[i]-1]+1;
else f[i]=T[w[i]]+1;
vis[w[i]]=1,T[w[i]]=f[i],ans=max(ans,f[i]);
}
cout<<n-ans<<endl;
return 0;
}
标签:序列 ret 变换 ons href org code span -o
原文地址:https://www.cnblogs.com/Tyher/p/9898565.html