BZOJ 3315: [Usaco2013 Nov]Pogo-Cow( dp )

我真想吐槽USACO的数据弱..= = O(n^3)都能A....上面一个是O(n²), 一个是O(n^3)
O(n^3)做法, 先排序, dp(i, j) = max{ dp(j, p) } + w( i ) ( t <= p <= j ) 表示跳到第 i 个点, 上一个点是在 j 的最大得分, 其中t是满足条件的最小p.
我们在计算dp(i, j) (1 <= j <= i )时会发现, 随着 j 的递减, t也在不断地减小, 这样我们只要在dp过程中维护h(i, j)表示 max{ dp(i, x) } ( j <= x <= i ), 然后逆序枚举 j, 维护t即可. 时间复杂度O(n²)
----------------------------------------------------------------------------
-----------------------------------------------------------------------------
3315: [Usaco2013 Nov]Pogo-Cow
Time Limit: 3 Sec Memory Limit: 128 MB
Submit: 185 Solved: 100
[Submit][Status][Discuss]
Description
In an ill-conceived attempt to enhance the mobility of his prize cow Bessie, Farmer John has attached a pogo stick to each of Bessie's legs. Bessie can now hop around quickly throughout the farm, but she has not yet learned how to slow down. To help train Bessie to hop with greater control, Farmer John sets up a practice course for her along a straight one-dimensional path across his farm. At various distinct positions on the path, he places N targets on which Bessie should try to land (1 <= N <= 1000). Target i is located at position x(i), and is worth p(i) points if Bessie lands on it. Bessie starts at the location of any target of her choosing and is allowed to move in only one direction, hopping from target to target. Each hop must cover at least as much distance as the previous hop, and must land on a target. Bessie receives credit for every target she touches (including the initial target on which she starts). Please compute the maximum number of points she can obtain.
一个坐标轴有N个点,每跳到一个点会获得该点的分数,并只能朝同一个方向跳,但是每一次的跳跃的距离必须不小于前一次的跳跃距离,起始点任选,求能获得的最大分数。
Input
* Line 1: The integer N.
* Lines 2..1+N: Line i+1 contains x(i) and p(i), each an integer in the range 0..1,000,000.
Output
* Line 1: The maximum number of points Bessie can receive.
Sample Input
5 6
1 1
10 5
7 6
4 8
8 10
INPUT DETAILS: There are 6 targets. The first is at position x=5 and is worth 6 points, and so on.
Sample Output
OUTPUT DETAILS: Bessie hops from position x=4 (8 points) to position x=5 (6 points) to position x=7 (6 points) to position x=10 (5 points).
从坐标为4的点,跳到坐标为5的,再到坐标为7和,再到坐标为10的。
HINT
Source
BZOJ 3315: [Usaco2013 Nov]Pogo-Cow( dp )的更多相关文章
- 【BZOJ】3315: [Usaco2013 Nov]Pogo-Cow(dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=3315 果然自己太弱. 想不出dp方程啊.. 其实,以后记住...与上一个状态或下一个状态有关,,可以 ...
- BZOJ 3314: [Usaco2013 Nov]Crowded Cows( 单调队列 )
从左到右扫一遍, 维护一个单调不递减队列. 然后再从右往左重复一遍然后就可以统计答案了. ------------------------------------------------------- ...
- bzoj 3312: [Usaco2013 Nov]No Change
3312: [Usaco2013 Nov]No Change Description Farmer John is at the market to purchase supplies for his ...
- BZOJ 1640: [Usaco2007 Nov]Best Cow Line 队列变换
Description FJ打算带着他可爱的N (1 ≤ N ≤ 2,000)头奶牛去参加"年度最佳老农"的比赛.在比赛中,每个农夫把他的奶牛排成一列,然后准备经过评委检验. 比赛 ...
- BZOJ 3314 [Usaco2013 Nov]Crowded Cows:单调队列
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3314 题意: N头牛在一个坐标轴上,每头牛有个高度.现给出一个距离值D. 如果某头牛在它的 ...
- BZOJ 1640 [Usaco2007 Nov]Best Cow Line 队列变换:贪心【字典序最小】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1640 题意: 给你一个长度为n的字符串. 你可以将原串的首字母或尾字母移动到新串的末尾. ...
- BZOJ3315: [Usaco2013 Nov]Pogo-Cow
3315: [Usaco2013 Nov]Pogo-Cow Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 143 Solved: 79[Submit] ...
- Bzoj3315 [Usaco2013 Nov]Pogo-Cow(luogu3089)
3315: [Usaco2013 Nov]Pogo-Cow Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 352 Solved: 181[Submit ...
- bzoj1742[Usaco2005 nov]Grazing on the Run 边跑边吃草*&&bzoj3074[Usaco2013 Mar]The Cow Run*
bzoj1742[Usaco2005 nov]Grazing on the Run 边跑边吃草 bzoj3074[Usaco2013 Mar]The Cow Run 题意: 数轴上有n棵草,牛初始在L ...
随机推荐
- Swift与Objective-C API的交互
互用性是让 Swift 和 Objective-C 相接合的一种特性,使你能够在一种语言编写的文件中使用另一种语言.当你准备开始把 Swift 融入到你的开发流程中时,你应该懂得如何利用互用性来重新定 ...
- HDU Computer Transformation1041 题解
Problem Description A sequence consisting of one digit, the number 1 is initially written into a com ...
- openstack之keystone
一.什么是keystone 用于为openstack家族中的其它组件成员提供统一的认证服务,包括身份认证.令牌发放和校验.服务列表.用户权限定义等: 基本概念: 用户User:用于身份认证.一个用户可 ...
- 没有login页面
"/"应用程序中的服务器错误. 无法找到资源. 说明:HTTP 404.您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用.请检查以下 URL 并确保 ...
- BZOJ 1599: [Usaco2008 Oct]笨重的石子( 枚举 )
直接枚举 ------------------------------------------------------------------------------- #include<cst ...
- 64位win8 配置Apache2.4+mod_msgi4.4.21+django1.8.6+python3.4
学习了很多前人分享的资料,整理如下: 安装步骤: 一.安装python3.4 下载 python-3.4.3.amd64.msi 直接安装 地址:https://www. ...
- word2vec代码解释
以前看的国外的一篇文章,用代码解释word2vec训练过程,觉得写的不错,转过来了 原文链接 http://nbviewer.jupyter.org/github/dolaameng/tutorial ...
- (IOS)多线程开发
一.线程的使用 以向网络请求一张图片为例 -(void)downURL:(NSURL *)aURL { NSData *d = [NSData dataWithContentsOfURL:aURL]; ...
- 深入探究VC —— 编译器cl.exe(1)
cl.exe的功能是将源代码文件编译为可提供链接器使用的obj对象文件.cl.exe命令行参数形式如下: CL (option...) file... [option | file]... [lib. ...
- linux下的压缩解压命令 tar 的简单描述
命令名称:tar 命令所在路径:/bin/tar 语法:tar选项·「-zcf」·「压缩后文件名」「目录」 -c 打包 -v 显示详细信息 -f 指定文件名 -z 打包同时压缩 tar命令解压缩语法: ...