贪心,HDU1257
http://acm.hdu.edu.cn/showproblem.php?pid=1257
贪心,一次把后面的高度或覆盖到前面比他高的上面,或自成一组
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<stdio.h> #include<string.h> int a[1000000],b[1000000]; int main() { int i,j,n,k; while(~scanf("%d",&n)) { k=0; memset(b,0,sizeof(b)); for(i=0;i<n;i++) { scanf("%d",&a[i]); for(j=0;j<=k;j++) { if(b[j]>a[i]) { b[j]=a[i]; break; } else if(j==k) { b[++k]=a[i]; break; } } } printf("%d\n",k); } return 0; }