Ferry Loading||
题意:题意:一条船能够一次最多渡n辆车过河,过河用t min,回来又要用t min。m辆车按照一定的计划到达岸边。现在要求最少
用多少时间就所有的船渡过河,以及用了最少多少次将所有。
题解:用贪心思想,最早运到对岸的时间,取决于最后来的一辆车的被运送时间,因此最优解就是最后一辆车能够最早被运送。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int cas,n,t,m,ll,train_timess,times;
int map[];
int main(){
scanf("%d",&cas);
while(cas--){
scanf("%d%d%d",&n,&t,&m);
for(int i=;i<=m;i++)
scanf("%d",&map[i]);
ll=m%n;train_timess=;times=;
if(ll==){
train_timess=m/n;
for(int i=n;i<m;i+=n){
times=max(map[n],times)+*t;
}
times=max(map[m],times)+t;
}
else{train_timess=m/n+;
times=map[ll]+*t;
for(int i=ll+n;i<m;i+=n){
times=max(times,map[i])+*t;
}
times=max(map[m],times)+t;
}
printf("%d %d\n",times,train_timess); }
}
Ferry Loading||的更多相关文章
- Ferry Loading III[HDU1146]
Ferry Loading IIITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- POJ-2336 Ferry Loading II(简单DP)
Ferry Loading II Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3763 Accepted: 1919 Desc ...
- POJ 2609 Ferry Loading(双塔DP)
Ferry Loading Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1807 Accepted: 509 Sp ...
- poj 2336 Ferry Loading II ( 【贪心】 )
Ferry Loading II Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3704 Accepted: 1884 ...
- poj-2336 Ferry Loading II(dp)
题目链接: Ferry Loading II Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3946 Accepted: ...
- TOJ 2419: Ferry Loading II
2419: Ferry Loading II Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KByteTotal Subm ...
- Ferry Loading II_贪心
Description Before bridges were common, ferries were used to transport cars across rivers. River fer ...
- [POJ2336]Ferry Loading II
题目描述 Description Before bridges were common, ferries were used to transport cars across rivers. Rive ...
- 【HDOJ】1406 Ferry Loading III
模拟,注意需要比较队头与当前时间的大小关系. #include <cstdio> #include <cstring> #include <cstdlib> #de ...
随机推荐
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(39)-在线人数统计探讨
原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(39)-在线人数统计探讨 系列目录 基于web的网站在线统计一直处于不是很精准的状态!基本上没有一种方法可 ...
- PHP本地环境搭配——WAMP不能启动, 一直处于红色图标或者橙色图标的解决办法
WAMP不能启动, 一直处于红色图标(正常启动为绿色吧) 考虑是端口的问题,我找到wamp文件夹中的wamp\bin\apache\apache2.2.22\conf路径下的httpd.conf文件, ...
- 从注冊流程 分析怎样安全退出多个Activity 多种方式(附DEMO)
前言 因为一个同学问到我怎样依照一个流程走好之后回到首页.我曾经看到过4个解决方式,后来发现有做个记录和总结的必要,就写了这篇博文. (之前看小强也写过一篇,这里通过自身的分析完整的总结一下下面6种方 ...
- ZEDBOARD启动自启配置(加载镜像) 分类: OpenCV ubuntu shell ZedBoard Eye_Detection 2014-11-08 18:53 167人阅读 评论(0) 收藏
参考:陆书14.2.8 1)备份ramdisk8M.image.gz 2)加载rootfs镜像文件: 3)在镜像目录下建立自己所需文件夹(挂载目录): 我需要的挂载目录有两个: root/qt/ins ...
- highgui.h备查 分类: C/C++ OpenCV 2014-11-08 18:11 292人阅读 评论(0) 收藏
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMP ...
- POJ 3277 City Horizon
标题效果: 每间房子的长度给出阴影(在间隔代表)而高度,求阴影总面积. 解题思路:矩形面积并. 以下是代码: #include <set> #include <map> #in ...
- [转]Android NDK几点回调方式
一.NDK中获取android设备ID的方式 Java代码如下(获取设备ANDROID_ID): final String androidId = Secure.getString(context.g ...
- Android 开发实践 ViewGroup 实现左右滑出窗口(一)
利用假期把以前做的东西总结整理一下,先从简单的开始吧.实现的效果是这样的: 做了个截屏动画,比例有点不对了,凑合着看吧. 整个窗口有3部分组成,中间的主界面是个列表,左边的滑出界面是个菜单,右边的 ...
- Winform 程序中dll程序集嵌入exe可执行文件
关于这方面,Google一下有很多方法,参考: http://blog.csdn.net/astonqa/article/details/7300856 但按照以上的方法我并没有成功,于是继续找到了一 ...
- c#中的interface abstract与virtual
interface用来声明接口1.只提供一些方法规约,不提供方法主体 如 public interface IPerson { void getName();//不包含方法主体 }2.方法不能 ...