POJ—1852—Ants—【入門題】【想法題】
阿新 • • 發佈:2019-02-20
Time Limit: 1000MS | Memory Limit: 30000K |
Total Submissions: 9698 | Accepted: 4285 |
Description
An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off it. When two ants meet they turn back and start walking in opposite directions. We know the original positions of ants on the pole, unfortunately, we do not know the directions in which the ants are walking. Your task is to compute the earliest and the latest possible times needed for all ants to fall off the pole.Input
Output
Sample Input
2 10 3 2 6 7 214 7 11 12 7 13 176 23 191
Sample Output
4 8 38 207
Source