U2 had to arrive at the concert venue within 17 minutes. They had to cross a bridge on the way. Four people started from the same end of the bridge. You had to help them reach the other end. The sky was dark, they only have one flashlight. At the same time, a maximum of two people can bridge the bridge together, while a flashlight must be held when crossing the bridge, so someone has to bring the flashlight back and forth to both ends of the bridge. A flashlight cannot be lost. The walking speed varies between the four people. If the two people walk with each other, the speed of the slow person prevails. Bono takes 1 minute to bridge the bridge, edge takes 2 minutes to bridge the bridge, Adam takes 5 minutes to bridge the bridge, and Larry takes 10 minutes to bridge the bridge. How do they bridge the bridge within 17 minutes?
Answer:
First time: 2 minutes for Bono and edge
Second time: Bono goes back for 1 minute
Third time: Adam and Larry for 10 minutes
Fourth time: Edge went back for 2 minutes (this may be the key point. The returned result may not have been just taken over. Alas, it was a short circuit, but I did not expect it)
Fifth: 2 minutes for Bono and edge
Total time: 2 + 1 + 10 + 2 + 2 = 17
--------------------------------
I'm thinking, how can I write this program?
17 minutes bridge Problem