【题解】

  显然是个DP题。

  设$f[i]$表示送$i$头牛过河所需的最短时间,预处理出$t[i]$表示一次性送i头牛过河所需时间,那么我们可以得到转移方程:$f[i]=min(f[i],f[i-j]+t[j]+t[0])$ (这里的$t[0]$指的是FJ独自过河的时间)

  这样就可以做一个$n$方的DP了

#include<cstdio>
#include<algorithm>
#define rg register
#define inf (1e9)
#define N (100010)
using namespace std;
int n,m,f[N],t[N];
inline int read(){
int k=0,f=1; char c=getchar();
while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
while('0'<=c&&c<='9')k=k*10+c-'0',c=getchar();
return k*f;
}
inline int min(int x,int y){return x<y?x:y;}
int main(){
n=read(); t[0]=read();
for(rg int i=1;i<=n;i++) t[i]=read()+t[i-1];
for(rg int i=1;i<=n;i++){
f[i]=inf;
for(rg int j=1;j<=i;j++) f[i]=min(f[i],f[i-j]+t[j]+t[0]);
}
printf("%d\n",f[n]-t[0]);
return 0;
}

  

BZOJ 1617 Usaco 2008 Mar. River Crossing渡河问题的更多相关文章

  1. BZOJ 1617: [Usaco2008 Mar]River Crossing渡河问题( dp )

    dp[ i ] = max( dp[ j ] + sum( M_1 ~ M_( i - j ) ) + M , sum( M_1 ~ M_i ) ) ( 1 <= j < i )  表示运 ...

  2. BZOJ 1617: [Usaco2008 Mar]River Crossing渡河问题

    题目 1617: [Usaco2008 Mar]River Crossing渡河问题 Time Limit: 5 Sec  Memory Limit: 64 MB Description Farmer ...

  3. 1617: [Usaco2008 Mar]River Crossing渡河问题(dp)

    1617: [Usaco2008 Mar]River Crossing渡河问题 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1219  Solved:  ...

  4. BZOJ1617: [Usaco2008 Mar]River Crossing渡河问题

    1617: [Usaco2008 Mar]River Crossing渡河问题 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 654  Solved: 4 ...

  5. [bzoj1617][Usaco2008 Mar]River Crossing渡河问题_动态规划

    River Crossing渡河问题 bzoj-1617 Usaco-2008 Mar 题目大意:题目链接. 注释:略. 想法:zcs0724出考试题的时候并没有发现这题我做过... 先把m求前缀和, ...

  6. 【BZOJ】1617: [Usaco2008 Mar]River Crossing渡河问题(dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1617 裸dp,很好做. 设f[i]表示i头牛到对岸所需最小时间.sum[i]表示运i头牛到对岸的时间 ...

  7. BZOJ 1617 [Usaco2008 Mar]River Crossing渡河问题:dp

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1617 题意: Farmer John以及他的N(1 <= N <= 2,500 ...

  8. [Usaco2008 Mar]River Crossing渡河问题[简单DP]

    Description Farmer John以及他的N(1 <= N <= 2,500)头奶牛打算过一条河,但他们所有的渡河工具,仅仅是一个木筏. 由于奶牛不会划船,在整个渡河过程中,F ...

  9. 【bzoj1617】[Usaco2008 Mar]River Crossing渡河问题 dp

    题目描述 Farmer John以及他的N(1 <= N <= 2,500)头奶牛打算过一条河,但他们所有的渡河工具,仅仅是一个木筏. 由于奶牛不会划船,在整个渡河过程中,FJ必须始终在木 ...

随机推荐

  1. [译]使用AssetBundle Manader

    AssetBundle and the AssetBundle Manager 介绍 AssetBundle允许从本地或者远程服务器加载Assets资源,利用AssetBundles技术,Assets ...

  2. mp3播放时间

    import os os_sep = os.sep this_file_abspath = os.path.abspath(__file__) this_file_dirname, this_file ...

  3. Codeforces Round #142 (Div. 2)B. T-primes

    B. T-primes time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...

  4. ZOJ 2397:Tian Ji -- The Horse Racing

    Tian Ji -- The Horse Racing Time Limit: 5 Seconds      Memory Limit: 32768 KB Here is a famous story ...

  5. [Codeplus 2017] 晨跑

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=5105 [算法] 答案为三个数的最小公倍数 [代码] #include<bits ...

  6. 懒人学习automake, Makefile.am,configure.ac

    已经存在Makefile.am,如何生成Makefile? 步骤: [root@localhost hello]# autoscan .///在当前文件夹中搜索 [root@localhost hel ...

  7. tinymce 富文本编辑器 编写资料

    tinymce官方文档: 粘贴图片插件 博客搬运地址 使用Blob获取图片并二进制显示实例页面 tinymce自动调整插件 是时候掌握一个富文本编辑器了——TinyMCE(1) XMLHttpRequ ...

  8. centos安装 memcached

    .安装 yum -y update yum install -y libevent libevent-devel yum install -y memcached 2.配置 vi /etc/sysco ...

  9. $ST表刷题记录$

    \(st表的题目不太多\) 我做过的就这些吧. https://www.luogu.org/problemnew/show/P3865 https://www.luogu.org/problemnew ...

  10. python值函数名的使用以及闭包,迭代器

    一.函数名的运用 函数名就是一个变量名,但它是一个特殊的变量名,是一个后面加括号可以执行函数的变量名. def func(): print("我是一个小小的函数") a = fun ...