#include<cstdio> #include<algorithm> using namespace std; int n,a[5001],b[5001],en; int main() { scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&a[i]); for(int i=1;i<=n;++i) { int *p=lower_bound(b+1,b+en+1,a[i]); if(!(*p)) ++en; (*p)=a[i]; } printf("%d\n",en); return 0; }
时间: 2024-11-05 08:53:30