Problem O
were common, ferries were used to transport cars across rivers.
River ferries, unlike their larger cousins, run on a guide line and
are powered by the river's current. Cars drive onto the ferry from
one end, the ferry crosses the river, and the cars exit from the
other end of the ferry.
There is a ferry across the river that can take n cars across the
river in t minutes and return in t minutes. m cars arrive at the
ferry terminal by a given schedule. What is the earliest time that
all the cars can be transported across the river? What is the
minimum number of trips that the operator must make to deliver all
cars by that time?
of input contains c, the number of test cases. Each test case
begins with n, t, m. m lines follow, each giving the arrival time
for a car (in minutes since the beginning of the day). The operator
can run the ferry whenever he or she wishes, but can take only the
cars that have arrived up to that time.
case, output a single line with two integers: the time, in minutes
since the beginning of the day, when the last car is delivered to
the other side of the river, and the minimum number of trips made
by the ferry to carry the cars within that time. < br><
br>You may assume that 0 < n, t, m < 1440. The arrival
times for each test case are in non-decreasing order.
10
3
#include
#define maxn 1444
using namespace std;
int main()
{
//freopen("in.txt", "r", stdin);
int
c,t,n,m,wait_time[maxn],times=0,time=0,lost_car=0;
scanf("%d",&c);
for(int
i=0;i
{
time=times=0;
scanf("%d%d%d",&n,&t,&m);
//printf("n=%d t=%d m=%d\n",n,t,m);
for(int j=1;j<=m;j++)
scanf("%d",&wait_time[j]);
lost_car=m%n;
times=m%n?m/n+1:m/n;//最少运输的次数;
if(lost_car)
time=wait_time[lost_car]+t*2;
//printf("此时时间是%d\n",time);
for(int j=1;j<=m/n;j++)//总共运times次;
{
//printf("wait_time[j*n+lost_car]=%d\n",wait_time[j*n+lost_car]);
//printf("time=%d\n",time);
if(time
{
time+=2*t+(wait_time[j*n+lost_car]-time);
if(j==m/n)
time-=t;//最后一次不用回去了
}
else//现在有车了
{
time+=2*t;
if(j==m/n)
time-=t;//最后一次不用回去了
}
//printf("此时时间是%d\n",time);
}
printf("%d %d\n",time,times);
}
}
Problem O的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- CDS测试框架介绍:如何为ABAP CDS Entities写测试
动机 现在大家都知道单元测试对我们代码的好处.并且我们都承认它是开发过程中不可或缺的一部分.但是在把代码切换到数据库的模式下的时候,我们被粗暴地打回了软件测试的黑暗年代...我们现在面临着逻辑下推到A ...
- 记录maven 整合SSM框架
一.新建maven项目 建好的项目结构如下图: 还需要做以下配置: 勾选上这两项后,就会自动生成 "src/main/java" 和 "src/main/resour ...
- c++builder中 扩展c++的关键字 : _published _automated Get/Set指令 _fastcall
C++Builder为C++增加了许多关键字,以适应其快速应用开发(RAD)环境.包括关键字和Get/Set指令. 1._published类似publich权限范围,_published像publi ...
- ES中const
前 言 EScript 上一次总结了,ES中let和var的区别,今天在带大家了解另一个声明关键词:const. const实际上保证的,并不是变量的值不得改动,而是变量指向的那个内存地址不得改 ...
- 系统出现异常: too many values to unpack (expected 2)
先感谢[ValueError: too many values to unpack](http://leonzhan.iteye.com/blog/1720315)系统出现异常:打开太多值(预期2)这 ...
- 文件上传之--内存溢出(System.OutOfMemoryException)
两周前就想把这点经验记录下来了,由于拖延症上身,直到刚才突然想起这件未完成的任务,今天是1024,在这个特别的日子里,祝所有程序猿兄弟姐妹们节日快乐! 上传功能一直很正常,直到上传了个500多兆的文件 ...
- 图片与字符串(base64编码)的转化
package com.demo; import java.util.*; import java.io.*; import sun.misc.BASE64Decoder; import sun.mi ...
- fatal: The remote end hung up unexpectedly
git push 的时候出错,提示: fatal: The remote end hung up unexpectedly 遇见几次了,原因是因为文件太大,把限制放宽就好了.命令: git confi ...
- 写博客 Why?
博客?英文名字为blogger,它是一种网络日记. 一.我为什么要写博客? 这是我第一回写博客,写的可能不是非常的好,请多多给些意见.在平常的学习的时候,我怕忘掉自己学的知识,常常都会记录下来,但回头 ...
- 安装阿里Java代码规约插件
概述 2017年10月14日杭州云栖大会,Java代码规约扫描插件全球首发仪式正式启动,规范正式以插件形式公开走向业界,引领Java语言的规范之路.目前,插件已在云效公有云产品中集成,立即体验!(云效 ...