【动态规划】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;
}
【动态规划】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 ...
- BZOJ 1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛( LIS )
裸的LIS ----------------------------------------------------------------- #include<cstdio> #incl ...
- 【BZOJ】1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛(lis)
http://www.lydsy.com/JudgeOnline/problem.php?id=1669 水题太严重 #include <cstdio> #include <cstr ...
- 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> #in ...
- 「BZOJ1669」D 饥饿的牛 [Usaco2006 Oct] Hungry Cows 牛客假日团队赛5 (LIS,离散化树状数组)
链接:https://ac.nowcoder.com/acm/contest/984/D 来源:牛客网 饥饿的牛 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言 ...
- BZOJ1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 5 ...
- bzoj:1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
Description 奶牛们又在玩一种无聊的数字游戏.输得很郁闷的贝茜想请你写个程序来帮她在开局时预测结果.在游戏的开始,每头牛都会得到一个数N(1<=N<=1,000,000).此时奶 ...
- 【BZOJ】1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏(刷水严重)
http://www.lydsy.com/JudgeOnline/problem.php?id=1666 这种我就不说了.. #include <cstdio> #include < ...
- 【BZOJ】1666 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
[算法]贪心&&堆 [题解]反过来看就是合并任意两块木板,花费为木板长度之和. 显然从最小的两块开始合并即可,用堆(优先队列)维护. 经典DP问题石子归并是只能合并相邻两堆石子,所以不 ...
随机推荐
- Codeforces 723d [暴力dfs]
/* 不要低头,不要放弃,不要气馁,不要慌张. 题意: 给n,m和k,n和m为所给矩阵的高和宽.k是要求最多剩下的湖的数量. 在所给的矩阵中,*代表陆地,.代表水. 湖的定义是一片连续的水(上下左右四 ...
- Ubuntu中启用关闭Network-manager网络设置问题!
Ubuntu中启用关闭Network-manager网络设置问题! [Server版本] 在UbuntuServer版本中,因为只存有命令行模式,所以要想进行网络参数设置,只能通过修改/etc/net ...
- c/c++运算顺序问题
发现没弄清楚这个问题的人很多,连我们c++老师都没弄清楚,转载一篇文章,以及C++ Primer原文. 裘宗燕:C/C++ 语言中的表达式求值 经常可以在一些讨论组里看到下面的提问:“谁知道下面C语句 ...
- 解决eclipse中安装AIX2插件问题
为了做webservice,查了下,需要用到AXIS2(当然也有别的方法,貌似更复杂,详情可以参看:java开发webservice的几种方式).可试了N次,下载的codegen和service插件始 ...
- js动态增加html页面元素
问题: <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2 ...
- javascript MVC(每天有学习一点篇)
“写的不是代码,是你的思维”,经常觉得自己写的代码“皮粗肉糙”的,看到那些要么精致小巧,要么优雅大方,要么光明磊落的代码时,常常会黯然神伤外加垂涎欲滴. why?(为什么我的代码不能如此..) whe ...
- [前端_EasyUI]给easyui的datebox设置默认值,获取不到 的解决方法
//给eayui datebox设置初始值 $("#ctime").datebox("setValue", function(){ var date = new ...
- ERROR SparkUncaughtExceptionHandler: Uncaught exception in thread
ERROR SparkUncaughtExceptionHandler: Uncaught exception in thread Thread[appclient-registration-retr ...
- WdatePicker 设置日期第一个比第二个的日期小
WdatePicker 设置日期第一个比第二个的日期小 可以设置,日期只显示某一天的,比如只显示周一,和周日 <input id="Text1" class="Wd ...
- Linux_04------Linux权限的设定
三种权限 */ /** * 修改文件所有者 * chown 用户名 文件名 */