Scenario
A group of N people must cross a dark, narrow bridge at night.
The bridge can support at most 2 people simultaneously.
The party possesses a single torch, which must be carried on every crossing (forward and return).
When 2 people cross together, they must move at the pace of the slower individual: time taken is max(ti,tj).
The sorted crossing times are t1≤t2≤⋯≤tN.
Your Task
- Formulate the dynamic programming recurrence relation that minimizes the total crossing time for N people.
- Detail the two candidate strategies (Strategy A vs Strategy B) for getting the two slowest individuals across.
- Solve for the classic benchmark T=[1,2,5,10] and determine the exact minimum time.
Constraints
- Individual times ti>0.
- At most 2 people on bridge at any moment.
Examples
For [1,2,5,10], Strategy B crosses 1 and 2, returns 1, crosses 5 and 10, returns 2, crosses 1 and 2, taking 2+1+10+2+2=17 minutes.