代码:
#include<bits/stdc++.h>
using namespace std;
#define MAXN 2e9
long long n,h[500005],x[500005],d[500005],cnt,f[500005];
int main(){
while(~scanf("%d",&x[n++]));
for(int i=0;i<n;i++)h[i]=-x[i];
fill(f,f+n,MAXN);
for(int i=0;i<n;i++)*upper_bound(f,f+n,h[i])=h[i];
printf("%d\n",lower_bound(f,f+n,MAXN)-f-1);
fill(f,f+n,MAXN);
for(int i=0;i<n;i++)*lower_bound(f,f+n,h[i])=h[i];
printf("%d",lower_bound(f,f+n,MAXN)-f-1);
return 0;
}
记录:这个