bzoj1669[Usaco2006 Oct]Hungry Cows饥饿的奶牛*
bzoj1669[Usaco2006 Oct]Hungry Cows饥饿的奶牛
题意:
求最长单调递增子序列,序列大小≤5000
题解:
蒟蒻弱写了一个O(n^2)的。
代码:
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define inc(i,j,k) for(int i=j;i<=k;i++) 5 #define maxn 5100 6 using namespace std; 7 8 inline int read(){ 9 char ch=getchar(); int f=1,x=0; 10 while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();} 11 while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); 12 return f*x; 13 } 14 int a[maxn],f[maxn],n; 15 int main(){ 16 n=read(); inc(i,1,n)a[i]=read(); 17 inc(i,1,n){ 18 f[i]=1; inc(j,1,i-1)if(a[j]<a[i])f[i]=max(f[i],f[j]+1); 19 } 20 inc(i,1,n)f[0]=max(f[0],f[i]); printf("%d",f[0]); return 0; 21 }
20160808
转载于:https://www.cnblogs.com/YuanZiming/p/5767342.html
bzoj1669[Usaco2006 Oct]Hungry Cows饥饿的奶牛*相关推荐
- [BZOJ1669][Usaco2006 Oct]Hungry Cows饥饿的奶牛
1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1000 Solved: 6 ...
- bzoj1669 [Usaco2006 Oct]Hungry Cows饥饿的奶牛
Description Farmer John养了N(1 <= N <= 5,000)头奶牛,每头牛都有一个不超过32位二进制数的正整数编号.FJ希望奶牛们在进食前,能按编号从小到大的顺序 ...
- bzoj 1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 990 Solved: 64 ...
- bzoj:1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
Description 奶牛们又在玩一种无聊的数字游戏.输得很郁闷的贝茜想请你写个程序来帮她在开局时预测结果.在游戏的开始,每头牛都会得到一个数N(1<=N<=1,000,000).此时奶 ...
- bzoj1669 Hungry Cows
Bzoj1669 饥饿的牛 注:bzoj1669好像需要买权限,好吧,大概听一下思路就好了,,代码并不清楚是否能AC 主要是求最长不下降子序列的的二分方法. [二分求最长不下降子序列(LIS)] [b ...
- bzoj 1667: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛(BFS)
1667: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛 Time Limit: 1 Sec Memory Limit: 64 MBSec Special Judge S ...
- BFS【bzoj1667】: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛
1667: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛 Description 经过跟Farmer John长达数年的谈判,奶牛们终于如愿以偿地得到了想要的旱冰鞋.农场上大 ...
- bzoj 1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富(DP)
1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富 Time Limit: 3 Sec Memory Limit: 64 MB Submit: 786 So ...
- bzoj1670【Usaco2006 Oct】Building the Moat 护城河的挖掘
1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 Time Limit: 3 Sec Memory Limit: 64 MB Submit: 387 Sol ...
最新文章
- java 初始化系统参数_系统中参数的初始化 参数在系统中配置
- 什么,PyTorch还能开发新药?哈佛推出这款工具包,10行代码训练“药神”模型...
- HTML 表单(form) 使用详解
- ssh遇到port 22:No route to host问题的解决方法
- 适合vue的富文本框
- C++函数调用运算符重载
- Nodejs入门【转载】保留备用
- jboss8日志级别设置_罐中研讨会:设置JBoss BRMS全日研讨会
- 英特尔预计5年内将成智能手机芯片大厂
- verilog 学习记(如何编写assert)
- php设计模式课程---7、装饰器模式如何使用
- ormlite的使用方法
- win10计算机管理字体糊,完美解决:Win10系统字体模糊解决教程
- 基于物联网的智能门锁应用系统设计方案
- Signal TapII 软件的使用
- java克隆实现_JAVA里的深克隆与浅克隆实现
- Chem 3D中怎么创建立体模型
- 我眼中的工程师的十个特质
- mac 特殊符号如何打
- Win7设置定时自动执行程序或脚本