BZOJ1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 665 Solved: 419
[Submit][Status]
Description
Input
Output
Sample Input
2 5 18 3 4 7 10 9 11 8 15
Sample Output
HINT
题解:
不用O(nlogn)也能过吧,不过不想写了,直接照搬上一题的代码
代码:
var a,sta:array[..] of longint;
i,top,n,j:longint;
function search(x:longint):longint;
var l,r,mid:longint;
begin
l:=;r:=top;
while l<>r do
begin
mid:=(l+r) div ;
if sta[mid]>x then r:=mid else l:=mid+;
end;
exit(l);
end;
function lis:longint;
begin
top:=;sta[]:=a[];
for i:= to n do
begin
if a[i]<sta[] then j:=
else if a[i]>=sta[top] then j:=top+
else j:=search(a[i]);
if j>top then begin inc(top);sta[top]:=a[i];end;
if a[i]<sta[j] then sta[j]:=a[i];
end;
exit(top);
end;
begin
assign(input,'input.txt');assign(output,'output.txt');
reset(input);rewrite(output);
readln(n);
for i:= to n do read(a[i]);
writeln(lis);
close(input);close(output);
end.
BZOJ1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛的更多相关文章
- 【动态规划】bzoj1669 [Usaco2006 Oct]Hungry Cows饥饿的奶牛
#include<cstdio> #include<algorithm> using namespace std; int n,a[5001],b[5001],en; int ...
- 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问题石子归并是只能合并相邻两堆石子,所以不 ...
随机推荐
- android本地定时通知
android本地通知略有不同,分为立即触发和延时触发 1.即时通知 android默认的Notification为立即触发 Intent intent = new Intent(Intent.ACT ...
- Pagekit安装
Pagekit 是一个模块化,轻量的 CMS 系统,基于现代化的技术,如 Symfony 组件和 Doctrine.它提供了一个很好的平台,用于主题和延伸开发.Pagekit 为您提供了工具来创造美丽 ...
- Spring整合CXF步骤,Spring实现webService,spring整合WebService
Spring整合CXF步骤 Spring实现webService, spring整合WebService >>>>>>>>>>>> ...
- jQuery模拟页面加载进度条
因为我们无法通过任何方法获取整个页面的大小和当前加载了多少,所以想制作一个加载进度条的唯一办法就是模拟.那要怎么模拟呢? 我们知道,页面是从上往下执行的,也就是说我们可以大致估算出在页面的某个位置加载 ...
- html 之前学习响应式的笔记
响应式的设计,根据用户设备的不同,用户屏幕大小不同,提供不同的网页设计http://mediaqueri.es/PhoneGap 使用2,如何模拟手机设备chome 浏览器 在32以上设备检测用 de ...
- js--小结⑤
js中的for循环,while循环,do...while循环和C语言的一模一样 有几个问题要提醒一下的是 1. null是对象,即object undefined是undefined d ...
- Oracle常用几种Sql用法
前几天客户提出一个月报,经过了解需求及公式等过程长达20小时,总算基本模型出来了,贴出来啥晒,对于我这种菜鸟来说也算小有提高,虽然Sql语句不是很庞大,但是里面涉及到了几种算法,个人觉得还是经常能用到 ...
- MITMF使用import error
安装问题: 1.ubuntu 14.04.安装使用capstone时候,提示出现import error:ERROR: fail to load the dynamic library. 解决方法:将 ...
- C#中堆和栈的区别分析(有待更新总结)
转载:http://blog.csdn.net/zevin/article/details/5721495 一.预备知识-程序的内存分配 一个由C/C++编译的程序占用的内存分为以下几个部分 1.栈区 ...
- 自己写的SqlHelper
using System; using System.Collections.Generic; using System.Configuration; using System.Data; using ...