正数形成从1到汽车数量的连续序列计算秒数,怎么采用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问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

2
js求问一个正则表达式的编写的问题,这里不能出现多个0开头怎么做?
2
求指教,为什么输入正数会出现两个值啊。哪个地方要修改
2
java简易计算器实现,添加能够切换简易计算器和科学计算器的按键。
2
求大佬帮我分析一下我的汇编程序出现的问题
1
1034 有理数四则运算 测试点2通过不了,求助
1
如何用while语句编写这个程序?
4
spark--java.lang.ArrayIndexOutOfBoundsException: 10582
1
1020 月饼 ,测试案例有三个不能通过,提示错误,求帮助!
3
关于float类型在计算机中的二进制表示的疑问
2
在fragment中edittext被键盘顶上去之后,输入框的下面外边距被遮挡住了
1
如何用C++理想地输出复数(更符合人们的书写习惯)
1
请问各位前辈,为什么相同功能的代码,会得出不同的结果?
1
C语言新手问题scanf函数将字符串指针用%c的格式输出结果是什么?
1
spark 出现很严重的数据倾斜,跑批时间很长,有时候会报错
2
用python 从键盘输入非0整数,以输入0为输入结束标志,求平均值,统计正数负数个数
1
三角形各个边长的组合的判断的算法问题,如何运用C程序设计技术来实现
0
请问这个程序用c怎么写?什么时候输出的序列不是单调递增?
2
matlab中,如何把一个带有变量的式子保持为正数
0
月饼——PTA问题求解(凡是需求量大于库存量的输出正确答案之后都有一个-1.#J是什么意思。。)
2
这个Java作业该如何实现?