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 ...
随机推荐
- 如何将ER图转换成关系模式集
在ER图中,主要是实体类型和联系类型. 1.实体类型的转换 (“——”表示对应关系) 实体类型——关系模式 实体的属性——关系模式的属性 实体标识符——关系模式的键 2.联系的转换 一元联系较简单,三 ...
- Delphi Format中的换行符号是什么
Delphi Format中的换行符号是什么 #,s1]); s3#'%s',[s,s1]); ShowMessage(s2); ShowMessage(s3); end; #13#10两边 ...
- 动态设置布局LayoutInflater
LayoutInflater作用是将layout的xml布局文件实例化为View类对象.LayoutInflater 的作用类似于 findViewById(),不同点是LayoutInflater是 ...
- insert当 sql语句里面有变量 为字符类型的时候 要3个单引号
set @InsertStr='INSERT INTO [dbo].[T_SchoolPercentMonth]([SchoolID],[MonthOfYear],[PercentNum]) VALU ...
- 关于SqlServer修改数据库常用信息的方法
--系统表里存放各个数据库属性信息的表之一SELECT name AS [Logical Name], physical_name AS [DB File Path],type_desc AS [Fi ...
- sql查看数据库表使用情况
如有更好的方式,希望交流. 感谢热心人,cc谢过 EXEC sys.sp_MSforeachtable @precommand = N'create table ##( 表名 sys ...
- 惠普 Compaq 6520s 无线开关打不开
问题描述:键盘上面的无线开关怎么按都打不开,始终是出于黄色的状态 解决方法:尝试恢复bios默认值测试: 开机不停点击F10进入bios,选择File选项,选择Restore Defaults-- ...
- iOS 延迟执行代码
//延迟执行 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)( * NSEC_PER_SEC)),dispatch_get_main ...
- IIViewDeckController的使用,左右拖拉菜单效果实现
博客园 IIViewDeckController的使用,左右拖拉菜单效果实现 很多应用里面都实现了对应的侧拉 显示隐藏的效果,看起来很符合用户体验的类似于这种 看起来很好看,今天去晚上搜下 ...
- JS 通过系统时间限定 动态添加 select option
虽然是个简单的效果,还是需要积累一下,记录一下: 在八月一号之后,删除最后一项,新添加2016级 — — 2015级 2014级 2013级 2012级 在六月一号之后,删除最后一项,新添加2016级 ...