Description

John养了一只叫Joseph的奶牛。一次她去放牛,来到一个非常长的一片地,上面有N块地方长了茂盛的草。我们可
以认为草地是一个数轴上的一些点。Joseph看到这些草非常兴奋,它想把它们全部吃光。于是它开始左右行走,吃
草。John和Joseph开始的时候站在p位置。Joseph的移动速度是一个单位时间一个单位距离。不幸的是,草如果长
时间不吃,就会腐败。我们定义一堆草的腐败值是从Joseph开始吃草到吃到这堆草的总时间。Joseph可不想吃太腐
败的草,它请John帮它安排一个路线,使得它吃完所有的草后,总腐败值最小。John的数学很烂,她不知道该怎样
做,你能帮她么?

Input

* Line 1 : Two space-separated integers: N and L. N<=1000
* Lines 2..N+1: Each line contains a single integer giving the position P of a clump (1 <= P <= 1,000,000).

Output

* Line 1: A single integer: the minimum total staleness Bessie can achieve while eating all the clumps.

Sample Input

4 10
1
9
11
19
INPUT DETAILS:
Four clumps: at 1, 9, 11, and 19. Bessie starts at location 10.

Sample Output

44
OUTPUT DETAILS:
Bessie can follow this route:
* start at position 10 at time 0
* move to position 9, arriving at time 1
* move to position 11, arriving at time 3
* move to position 19, arriving at time 11
* move to position 1, arriving at time 29
giving her a total staleness of 1+3+11+29 = 44. There are other routes
with the same total staleness, but no route with a smaller one.44
 
 

 
 
感觉翻译的不太好..但也能看2333.
发现了三倍经验,但都是权限题2333.
对于我这种非权限汪很不友好...
然而凭借三道题成功将yousiki学长刷题量冲到日榜第45...
虽然不知道干了些什么昨天我日榜第5.玄学我都不知道昨天做了些什么2333;
 
吐槽结束。
水水的区间dp秒出思路,,,
设f[i][j][0/1]表示处理完了i~j区间,现在在左端点/右端点的最小损失。
于是f[i][j][0] 可以从 f[i+1][j][0/1]转移过来,f[i][j][1] 可以从 f[i][j-1][0/1]转移过来。。
我也是第一次见区间dp没有枚举k...见识太少了233
 

 
贴那篇题解呢。。。
对了注意bzoj3074和另外两个不太一样,从输入可以看出来。
这里贴bzoj1694的。
// By BriMon
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
inline int read(){
int res=;char ch=getchar();
while(!isdigit(ch)) ch=getchar();
while(isdigit(ch)){res=(res<<)+(res<<)+(ch^);ch=getchar();}
return res;
} int n, x;
int f[][][], pos[]; int main()
{
n = read(), x = read();
for (int i = ; i <= n ; i ++)
pos[i] = read();
sort(pos + , pos + + n);
memset(f, 0x3f, sizeof f);
for (int i = ; i <= n ; i ++) f[i][i][] = f[i][i][] = abs(x - pos[i]) * n;
for (int len = ; len <= n ; len ++)
{
for (int i = ; i <= n ; i ++)
{
int j = i + len - ;
if (j > n) break;
f[i][j][] = min(f[i][j][], min(f[i+][j][] + (n - (j - i)) * (pos[j] - pos[i]), f[i+][j][] + (n - (j - i)) * (pos[i+] - pos[i])));
f[i][j][] = min(f[i][j][], min(f[i][j-][] + (n - (j - i)) * (pos[j] - pos[j-]), f[i][j-][] + (n - (j - i)) * (pos[j] - pos[i])));
}
}
printf("%d\n", min(f[][n][], f[][n][]));
return ;
}

[BZOJ1694/1742/3074]The Cow Run 三倍经验的更多相关文章

  1. 洛谷P3080 [USACO13MAR]牛跑The Cow Run

    P3080 [USACO13MAR]牛跑The Cow Run 题目描述 Farmer John has forgotten to repair a hole in the fence on his ...

  2. 「USACO13MAR」「LuoguP3080」 牛跑The Cow Run (区间dp

    题目描述 Farmer John has forgotten to repair a hole in the fence on his farm, and his N cows (1 <= N ...

  3. 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 ...

  4. bzoj2581 [USACO 2012 Jan Gold] Cow Run【And-Or Tree】

    传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=110 传送门2:http://www.lydsy.com/JudgeOn ...

  5. BZOJ-USACO被虐记

    bzoj上的usaco题目还是很好的(我被虐的很惨. 有必要总结整理一下. 1592: [Usaco2008 Feb]Making the Grade 路面修整 一开始没有想到离散化.然后离散化之后就 ...

  6. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  7. Usaco2012-2013 金组 题解 (暂缺Hill walk以及Figue eight)

    https://files.cnblogs.com/files/Winniechen/usaco2012-2013.pdf 做的不是很好,还请见谅! 如果有什么疑问,可以QQ上找我. QQ号:1967 ...

  8. BZOJ 1742: [Usaco2005 nov]Grazing on the Run 边跑边吃草( dp )

    dp... dp( l , r , k )  , 表示 吃了[ l , r ] 的草 , k = 1 表示最后在 r 处 , k = 0 表示最后在 l 处 . ------------------- ...

  9. bzoj 1742: [Usaco2005 nov]Grazing on the Run 边跑边吃草【区间dp】

    挺好的区间dp,状态设计很好玩 一开始按套路设f[i][j],g[i][j]为吃完(i,j)区间站在i/j的最小腐败值,后来发现这样并不能保证最优 实际上是设f[i][j],g[i][j]为从i开始吃 ...

随机推荐

  1. Java第二次作业第一题

    编写图形界面程序,在窗体中设置菜单栏,在菜单栏上添加"file"菜单,在文件菜单中添加"new"和"quit"两个菜单项,其中"q ...

  2. log4j日志不输出的问题

    今天服务器上报错,想先去看一下日志进行排查,结果发现日志很久都没有输出过了.从上午排查到下午,刚刚解决,因此记录一下,但现在也只是知其然,并不知其所以然,所以如果大家有什么想法请在下方评论. 先说一下 ...

  3. [AI] 深度数据 - Data

    Data Engineering Data  Pipeline Outline [DE] How to learn Big Data[了解大数据] [DE] Pipeline for Data Eng ...

  4. 神奇的互换身体术--java的类型擦除

    故事背景 <互换身体>是由环球影业发行的喜剧电影,于2011年8月5日在美国上映.该片由大卫·道金执导,瑞安·雷诺兹.杰森·贝特曼.奥利维亚·王尔德等主演.该片讲述了一位居家好男人和一位蜂 ...

  5. Jmeter日记,很乱很随意

    这个笔记是写给自己看的,很乱很随意,可能以后自己都看不懂.哈哈 Jmeter两种录制方式: 1使用badboy 2.使用代理 浏览器设置代理 参数化 随机参数化 插件的使用 官网下载和说明https: ...

  6. Spring boot 梳理 - 模版引擎 -freemarker

    开发环境中关闭缓存 spring: thymeleaf: cache: false freemarker: cache: false Spring boot 集成 freemarker <dep ...

  7. 【PCIE-1】---Pcie基本概念普及(扫盲篇--巨适合新手)

    PCIE由早期得PCI扩展衍生而来并且对兼容PCI,两者得主要区别在于并行到串行得切换,且速率更快.目前主板上越来越多得设备都挂载到PCI总线下面,甚至部分硬盘也会挂载PCI总线下面,可见PCIE得应 ...

  8. webpack原理

    webpack早就已经在前端领域大放异彩,会使用和优化webpack也已经是中.高级工程师必备技能,在此基础之上再对webpack的原理进行理解和掌握,必定会在未来的开发中事半功倍.若是对于webpa ...

  9. Eclipse利用Maven快速上手搭建MyBatis

    一.what is maven? Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的项目管理工具软件. Maven 除了以程序构建能力为特色之外,还提供高级项目管理 ...

  10. 1 Processing入门简介

    1 Processing入门简介 1.1 Before you start Processing是一个为开发面向图形的应用(visually oriented application)而生的简单易用的 ...