【动态规划】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;
}
时间: 2024-11-05 08:53:30

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

BZOJ1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛

1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 665  Solved: 419[Submit][Status] Description Farmer John养了N(1 <= N <= 5,000)头奶牛,每头牛都有一个不超过32位二进制数的正整数编号.FJ希望奶牛们在进食前,能按编号从小到大的顺序排好队,但奶牛们从不听他的话.为了让奶牛们养成这个习惯,每次开饭时,FJ从奶

bzoj 1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛【dp+树状数组+hash】

最长上升子序列.虽然数据可以直接n方但是另写了个nlogn的 转移:f[i]=max(f[j]+1)(a[j]<a[i]) O(n^2) #include<iostream> #include<cstdio> using namespace std; const int N=5005; int n,a[N],f[N],ans; int read() { int r=0,f=1; char p=getchar(); while(p>'9'||p<'0') { if(

[BZOJ1666][Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏

1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 849  Solved: 746 [Submit][Status][Discuss] Description 奶牛们又在玩一种无聊的数字游戏.输得很郁闷的贝茜想请你写个程序来帮她在开局时预测结果.在游戏的开始,每头牛都会得到一个数N(1<=N<=1,000,000).此时奶牛们的分数均为0.如果N

bzoj1670【Usaco2006 Oct】Building the Moat 护城河的挖掘

1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 Time Limit: 3 Sec  Memory Limit: 64 MB Submit: 387  Solved: 288 [Submit][Status][Discuss] Description 为了防止口渴的食蚁兽进入他的农场,Farmer John决定在他的农场周围挖一条护城河.农场里一共有N(8<=N<=5,000)股泉水,并且,护城河总是笔直地连接在河道上的相邻的两股泉水.护城河必须能保护

BZOJ 1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富( dp )

dp , dp[ i ][ j ] = max( dp[ k ][ j - 1 ] ) ( i - 1 <= k <= i + 1 , dp[ k ][ j - 1 ] > 0 ) 一开始没注意到要 dp[ k ][ j - 1 ] > 0 才能取 , 然后就WA 了2次... -------------------------------------------------------------------------- #include<cstdio> #incl

1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富

1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 498  Solved: 289[Submit][Status] Description 最近,奶牛们热衷于把金币包在面粉里,然后把它们烤成馅饼.第i块馅饼中含有Ni(1<=Ni<=25)块金币,并且,这个数字被醒目地标记在馅饼表面. 奶牛们把所有烤好的馅饼在草地上排成了一个R行(1<=R<=100)

BZOJ1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富

1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 459  Solved: 268[Submit][Status] Description 最近,奶牛们热衷于把金币包在面粉里,然后把它们烤成馅饼.第i块馅饼中含有Ni(1<=Ni<=25)块金币,并且,这个数字被醒目地标记在馅饼表面. 奶牛们把所有烤好的馅饼在草地上排成了一个R行(1<=R<=100)

【BFS】Power Hungry Cows

Power Hungry Cows Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5522   Accepted: 1384 Description FJ's cows would like to be able to compute integer powers P (1 <= P <= 20,000) of numbers very quickly, but need your help. Because they

[BZOJ1670][Usaco2006 Oct]Building the Moat护城河的挖掘

1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 Time Limit: 3 Sec  Memory Limit: 64 MB Submit: 628  Solved: 466 [Submit][Status][Discuss] Description 为了防止口渴的食蚁兽进入他的农场,Farmer John决定在他的农场周围挖一条护城河.农场里一共有N(8<=N<=5,000)股泉水,并且,护城河总是笔直地连接在河道上的相邻的两股泉水.护城河必须能保护