博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
P2904 [USACO08MAR]跨河River Crossing
阅读量:5292 次
发布时间:2019-06-14

本文共 1977 字,大约阅读时间需要 6 分钟。

 如有乱码,请

 

题目描述

Farmer John is herding his N cows (1 <= N <= 2,500) across the expanses of his farm when he finds himself blocked by a river. A single raft is available for transportation.

FJ knows that he must ride on the raft for all crossings and that that adding cows to the raft makes it traverse the river more slowly.

When FJ is on the raft alone, it can cross the river in M minutes (1 <= M <= 1000). When the i cows are added, it takes M_i minutes (1 <= M_i <= 1000) longer to cross the river than with i-1 cows (i.e., total M+M_1 minutes with one cow, M+M_1+M_2 with two, etc.). Determine the minimum time it takes for Farmer John to get all of the cows across the river (including time returning to get more cows).

Farmer John以及他的N(1 <= N <= 2,500)头奶牛打算过一条河,但他们所有的渡河工具,仅仅是一个木筏。 由于奶牛不会划船,在整个渡河过程中,FJ必须始终在木筏上。在这个基础上,木筏上的奶牛数目每增加1,FJ把木筏划到对岸就得花更多的时间。 当FJ一个人坐在木筏上,他把木筏划到对岸需要M(1 <= M <= 1000)分钟。当木筏搭载的奶牛数目从i-1增加到i时,FJ得多花M_i(1 <= M_i <= 1000)分钟才能把木筏划过河(也就是说,船上有1头奶牛时,FJ得花M+M_1分钟渡河;船上有2头奶牛时,时间就变成M+M_1+M_2分钟。后面的依此类推)。那么,FJ最少要花多少时间,才能把所有奶牛带到对岸呢?当然,这个时间得包括FJ一个人把木筏从对岸划回来接下一批的奶牛的时间。

输入格式

* Line 1: Two space-separated integers: N and M

* Lines 2..N+1: Line i+1 contains a single integer: M_i

输出格式

* Line 1: The minimum time it takes for Farmer John to get all of the cows across the river.

输入输出样例

输入 #1复制
5 10 3 4 6 100 1
输出 #1复制
50

说明/提示

There are five cows. Farmer John takes 10 minutes to cross the river alone, 13 with one cow, 17 with two cows, 23 with three, 123 with four, and 124 with all five.

Farmer John can first cross with three cows (23 minutes), then return (10 minutes), and then cross with the last two (17 minutes). 23+10+17 = 50 minutes total.

 

#include
#include
using namespace std;const int N=2503;int n,m,i,j,a[N],f[N];int min(int x,int y){ return x
>n>>m; m*=2; for(i=1;i<=n;i++){ cin>>a[i]; a[i]+=a[i-1]; f[i]=a[i]+m; for(j=1;j

  

转载于:https://www.cnblogs.com/xiongchongwen/p/11484065.html

你可能感兴趣的文章
安装webpack-dev-server后,npm run dev报错
查看>>
[BZOJ4567][SCOI2016]背单词(Trie+贪心)
查看>>
git回退到某个版本并提交
查看>>
查看oracle数据库的连接数以及用户
查看>>
简单几行js实现tab选项切换效果
查看>>
关于更改滚动条样式
查看>>
【数据结构】栈结构操作示例
查看>>
中建项目环境迁移说明
查看>>
三.野指针和free
查看>>
VIO的Bundle Adjustment推导
查看>>
activemq5.14+zookeeper3.4.9实现高可用
查看>>
asp.net FileUpload控件文件格式的判断及文件大小限制
查看>>
angular(1.5.8)
查看>>
h5的video标签支持的视频格式
查看>>
TCP/IP详解学习笔记(3)IP协议ARP协议和RARP协议
查看>>
简单【用户输入验证】
查看>>
学android:直接用jdk来helloworld
查看>>
Access Jira RESTful API by cURL
查看>>
python tkinter GUI绘制,以及点击更新显示图片
查看>>
Spark基础脚本入门实践3:Pair RDD开发
查看>>