You are given a group of people and a bridge. Each person has a specific time it takes for them to cross the bridge. The goal is to find the minimum total time required for all people to cross from one side of the bridge to the other.
Here are the rules:
Your task is to implement a function that calculates the minimum total time.
[1, 2]
2
The two people (with times 1 and 2) cross together. They move at the speed of the slower person (2 minutes). All people are now on the other side.
[1, 2, 5]
8
Sorted times: [1, 2, 5].
[1, 2, 5, 10]
17
Sorted times: [1, 2, 5, 10]. This scenario often uses a greedy strategy:
[1, 2]
2