There are
Worker i requires specific durations given by time[i] = [left_i, pick_i, right_i, put_i]:
left_i: time to cross the bridge from the left bank to the right bank.
pick_i: time to pick up a box from the right bank.
right_i: time to cross the bridge from the right bank to the left bank.
put_i: time to put down a box on the left bank.
A worker i is considered less efficient than worker j if:
left_i + right_i > left_j + right_j, or
left_i + right_i == left_j + right_j and i > j.
The bridge usage follows these priority rules:
If workers are waiting on both sides of the bridge, workers crossing from the right bank to the left bank always have higher priority.
If multiple workers on the same bank are ready to cross, the least efficient worker among them crosses first.
If all
When worker i crosses to the right bank, they immediately spend pick_i time picking up a box, and then wait to cross back to the left bank. After crossing back to the left bank, they immediately spend put_i time placing the box down, after which they are available on the left bank again.
Return the timestamp at which the final worker carrying the last box finishes crossing the bridge to the left bank.
Constraints:
n, k
time.length k
time[i].length
left_i, pick_i, right_i, put_i
There are
Worker i requires specific durations given by time[i] = [left_i, pick_i, right_i, put_i]:
left_i: time to cross the bridge from the left bank to the right bank.
pick_i: time to pick up a box from the right bank.
right_i: time to cross the bridge from the right bank to the left bank.
put_i: time to put down a box on the left bank.
A worker i is considered less efficient than worker j if:
left_i + right_i > left_j + right_j, or
left_i + right_i == left_j + right_j and i > j.
The bridge usage follows these priority rules:
If workers are waiting on both sides of the bridge, workers crossing from the right bank to the left bank always have higher priority.
If multiple workers on the same bank are ready to cross, the least efficient worker among them crosses first.
If all
When worker i crosses to the right bank, they immediately spend pick_i time picking up a box, and then wait to cross back to the left bank. After crossing back to the left bank, they immediately spend put_i time placing the box down, after which they are available on the left bank again.
Return the timestamp at which the final worker carrying the last box finishes crossing the bridge to the left bank.
Constraints:
n, k
time.length k
time[i].length
left_i, pick_i, right_i, put_i