Tower Parking 怎么去做

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
MAP数据结构在搜寻算法的运用,采用C语言的程序的设计的思路解决
0
积木的堆叠的一个算法的实现,怎么利用C语言的程序的设计的方式来编写
0
利用数组原理计算覆盖率的问题的算法,怎么使用C语言的程序的代码的编写的思路实现的?
0
正数形成从1到汽车数量的连续序列计算秒数,怎么采用C语言的程序代码设计的思路去成功实现?
0
停车塔的数据结构建模和计算问题,怎么利用C语言的程序的代码的编写的思想方法去很好实现的
0
搭砖块的排列方式的问题,怎么采用C语言的程序的编写的设计的技术怎么实现这个排列组织的
0
建造一座塔楼并最大化塔楼的高度使用的积木的计算,怎么采用C语言的代码的编写的过程来实现的呢
0
计算是否可以成功地进行塔防,怎么采用C语言的程序的设计的编写的技术来完成的
0
峡谷内位置的移动的计算,怎么使用C语言的程序的设计的代码的过程有效加以实现的呢
0
有大佬可以解释一下这个代码吗?
0
Tower Parking 怎么用C语言的程序来实现
0
这里Build the Tower问题用C语言的解答方法
0
C语言程序来实现 Tower Parking
0
远足的计算问题寻找路线怎么用 C语言
0
递归是怎么运用的问题,Towers of Hanoi
0
具体的代码的实现,Pirate's Chest
0
算法的一个设计问题,Cover The Enemy
0
Signal Interference
0
Frontier 曲线问题