Tower Parking 怎么用C语言的程序来实现

Problem Description
There is a new revolution in the parking lot business: the parking tower. The concept is simple: you drive your car into the elevator at the entrance of the tower, and the elevator and conveyor belts drag the car to an empty parking spot, where the car remains until you pick it up. When you return, the elevator and conveyor belts move your car back to the entrance and you’re done.

The layout of the tower is simple. There is one central elevator that transports the cars between the different floors. On each floor there is one giant circular conveyor belt on which the cars stand. This belt can move in clockwise and counterclockwise direction. When the elevator arrives on a floor, it becomes part of the belt so that cars can move through it.

At the end of the day the tower is usually packed with cars and a lot of people come to pick them up. Customers are processed in a first come first serve order: the elevator is moved to the floor of the first car, the conveyor belt moves the car on the elevator, the elevator is moved down again, and so on. We like to know how long it takes before the last customer gets his car. Moving the elevator one floor up- or downwards takes 10 seconds and moving a conveyor belt one car in either direction takes 5 seconds.

Input
On the first line one positive number: the number of testcases, at most 100. After that per testcase:

One line with two integers h and l with 1 ≤ h ≤ 50 and 2 ≤ l ≤ 50: the height of the parking tower and the length of the conveyor belts.

h lines with l integers: the initial placement of the cars. The jth number on the ith line describes the jth position on the ith floor. This number is -1 if the position is empty, and r if the position is occupied by the rth car to pick up. The positive numbers form a consecutive sequence from 1 to the number of cars. The entrance is on the first floor and the elevator (which is initially empty) is in the first position. There is at least one car in the parking tower.

Output
Per testcase:

One line with the number of seconds before the last customer is served.

Sample Input
2
1 5
-1 2 1 -1 3
3 6
-1 5 6 -1 -1 3
-1 -1 7 -1 2 9
-1 10 4 1 8 -1

Sample Output
25
320

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

0
区间整数遍历问题,子序列的遍历怎么使用C语言算法计算实现?
0
一个堆放的问题,求教用C语言的办法的解决,怎么实现,具体的思路
0
MAP数据结构在搜寻算法的运用,采用C语言的程序的设计的思路解决
0
信号的干涉的一个算法问题,怎么用C程序的设计的语言来求解的呢
0
积木的堆叠的一个算法的实现,怎么利用C语言的程序的设计的方式来编写
1
不等式的关系的判断计算的算法,利用C程序的语言的程序编写的思路的做法?
0
关系不等式在开销的计算的问题,这个问题如何运用的C语言的程序的设计的办法去实现?
0
利用数组原理计算覆盖率的问题的算法,怎么使用C语言的程序的代码的编写的思路实现的?
0
用字符构成的立体方块图的算法,怎么采用C程序的代码语言的编写的过程实现?
0
等比数列的推断问题,怎么利用的C程序语言代码编写手段方式去实现的呢?
0
由字符串构成的一个立方体的图案的生成,怎么利用C程序语言代码编写的方式来进行的?
0
DataTable内容正常,Response.Flush()或者Response.End()后无文件输出到客户端?
0
正数形成从1到汽车数量的连续序列计算秒数,怎么采用C语言的程序代码设计的思路去成功实现?
0
停车塔的数据结构建模和计算问题,怎么利用C语言的程序的代码的编写的思想方法去很好实现的
0
搭砖块的排列方式的问题,怎么采用C语言的程序的编写的设计的技术怎么实现这个排列组织的
0
建造一座塔楼并最大化塔楼的高度使用的积木的计算,怎么采用C语言的代码的编写的过程来实现的呢
0
使用ascii画出正方体的问题,怎么使用C语言的程序的设计的形式来回答的,代码的实现
0
计算是否可以成功地进行塔防,怎么采用C语言的程序的设计的编写的技术来完成的
0
峡谷内位置的移动的计算,怎么使用C语言的程序的设计的代码的过程有效加以实现的呢
0
有大佬可以解释一下这个代码吗?