【动态规划】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\n",en);
    return 0;
}
posted @ 2015-06-24 09:38  AutSky_JadeK  阅读(194)  评论(0编辑  收藏  举报
TVアニメ「Charlotte(シャーロット)」公式サイト TVアニメ「Charlotte(シャーロット)」公式サイト