【动态规划】bzoj1669 [Usaco2006 Oct]Hungry Cows饥饿的奶牛

#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
",en);
    return 0;
}
原文地址:https://www.cnblogs.com/autsky-jadek/p/4596869.html