You are traveling along a straight road of length l, starting at position l. Along the road, there are n road signs located at coordinates given by the array position, where position[0] = 0 and position[n - 1] = l. Each sign time[i], required to traverse the road segment starting from position[i] to the next sign position[i + 1].
You are allowed to perform at most k merge operations on adjacent inner signs (signs that are neither at position l). In a single merge operation, you can choose an inner sign at index i (m is the current number of signs), remove it, and add its time[i] value to the next sign at index i + 1 (so the new time for the sign at index i + 1 becomes time[i] + time[i + 1]).
The total travel time is the sum of (position[j + 1] - position[j]) * time[j] across all remaining segments from
Return the minimum total travel time possible after performing at most k merge operations.
Constraints:
l
n l
k n
position.length n
position[0] position[n - 1] l
position is sorted in strictly increasing order.
time.length n
time[i]
time
You are traveling along a straight road of length l, starting at position l. Along the road, there are n road signs located at coordinates given by the array position, where position[0] = 0 and position[n - 1] = l. Each sign time[i], required to traverse the road segment starting from position[i] to the next sign position[i + 1].
You are allowed to perform at most k merge operations on adjacent inner signs (signs that are neither at position l). In a single merge operation, you can choose an inner sign at index i (m is the current number of signs), remove it, and add its time[i] value to the next sign at index i + 1 (so the new time for the sign at index i + 1 becomes time[i] + time[i + 1]).
The total travel time is the sum of (position[j + 1] - position[j]) * time[j] across all remaining segments from
Return the minimum total travel time possible after performing at most k merge operations.
Constraints:
l
n l
k n
position.length n
position[0] position[n - 1] l
position is sorted in strictly increasing order.
time.length n
time[i]
time