#include #include #include #include #include #include #include #include #include #include #include #include #define mem(x,y) memset(x,y,sizeof(x)) #define pb push_back using namespace std; typedef long long ll; typedef pair pii; #define bug puts("==========="); const double pi=(acos(-1.0)); const double eps=1e-8; const ll INF=1e18+10; const int inf=1e9+10; const int maxn=100000+5; const int mod=1e9+7; int le[maxn]; int dp[maxn]; int a[maxn]; int bins(int len,int n) { int l=0,r=len,m; while(l<=r){ m=(l+r)>>1; if(dp[m]>n)r=m-1; else if(dp[m]dp[len])dp[++len]=a[i],le[i]=len; else{ int k=bins(len,a[i]); dp[k]=a[i]; le[i]=k; } } for(int i=0;i