CarTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1487 Accepted Submission(s): 428
Problem Description
Ruins is driving a car to participating in a programming contest. As on a very tight schedule, he will drive the car without any slow down, so the speed of the car is non-decrease real number.
Of course, his speeding caught the attention of the traffic police. Police record N positions of Ruins without time mark, the only thing they know is every position is recorded at an integer time point and Ruins started at 0 . Now they want to know the minimum time that Ruins used to pass the last position.
Input
First line contains an integer
T
, which indicates the number of test cases.
Every test case begins with an integers N , which is the number of the recorded positions. The second line contains N numbers a1 , a2 , ⋯ , aN , indicating the recorded positions. Limits 1≤T≤100 1≤N≤105 0<ai≤109 ai<ai+1
Output
For every test case, you should output
'Case #x: y', where
x indicates the case number and counts from
1 and
y is the minimum time.
Sample Input
Sample Output
Source
Recommend
题意
一辆车开始行驶,速度不会减慢;给出两点之间的距离,
每一次记录的花费时间都是整数,让你求出最小时间花费
思路
由于速度不会减小,且花费时间都是整数,则倒着来
最后两点之间的速度最大,且时间最小,v=a[n]-a[n-1];
这之前的速度<=之后的速度
|
CarTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1487 Accepted Submission(s): 428
Problem Description
Ruins is driving a car to participating in a programming contest. As on a very tight schedule, he will drive the car without any slow down, so the speed of the car is non-decrease real number.
Of course, his speeding caught the attention of the traffic police. Police record N positions of Ruins without time mark, the only thing they know is every position is recorded at an integer time point and Ruins started at 0 . Now they want to know the minimum time that Ruins used to pass the last position.
Input
First line contains an integer
T
, which indicates the number of test cases.
Every test case begins with an integers N , which is the number of the recorded positions. The second line contains N numbers a1 , a2 , ⋯ , aN , indicating the recorded positions. Limits 1≤T≤100 1≤N≤105 0<ai≤109 ai<ai+1
Output
For every test case, you should output
'Case #x: y', where
x indicates the case number and counts from
1 and
y is the minimum time.
Sample Input
Sample Output
Source
Recommend
|