题目描述
<p class="p0" style="text-align:justify;"> <span style="font-size:12.0000pt;font-family:'宋体';">An army of ants walk on a horizontal pole of length l cm, each with a constant speed</span> </p> <p class="p0" style="text-align:justify;"> <span style="font-size:12.0000pt;font-family:'宋体';"> of 1 cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off </span> </p> <p class="p0" style="text-align:justify;"> <span style="font-size:12.0000pt;font-family:'宋体';">it. When two ants meet they turn back and start walking in opposite directions. We</span> </p> <p class="p0" style="text-align:justify;"> <span style="font-size:12.0000pt;font-family:'宋体';"> know the original positions of ants on the pole, unfortunately, we do not know the </span> </p> <p class="p0" style="text-align:justify;"> <span style="font-size:12.0000pt;font-family:'宋体';">directions in which the ants are walking. Your task is to compute the earliest and </span> </p> <p class="p0" style="text-align:justify;"> <span style="font-size:12.0000pt;font-family:'宋体';">the latestpossible times needed for all ants to fall off the pole.</span><span style="font-size:12.0000pt;font-family:'宋体';"></span> </p>
输入格式
<p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';">The first line of input contains one integer giving the number of cases that follow.</span> </p> <p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';"> The data for each case start with two integer numbers: the length of the pole (in cm)</span> </p> <p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';"> and n, the number of ants residing on the pole. These two numbers are followed by n i</span> </p> <p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';">ntegers giving the position of each ant on the pole as the distance measured from the </span> </p> <p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';">left end of the pole, in no particular order. All input integers are not bigger than 1</span> </p> <p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';">000000 and they are separated by whitespace.</span> </p>
输出格式
<p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';">For each case of input, output two numbers separated by a single space. The first </span> </p> <p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';">number is the earliest possible time when all ants fall off the pole (if the direction</span> </p> <p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';">s of their walks are chosen appropriately) and the second number is the latest possibl</span> </p> <p class="p0"> <span style="font-size:12.0000pt;font-family:'宋体';">e such time.</span><span style="font-size:12.0000pt;font-family:'宋体';"></span> </p>
样例
样例输入 1
2
10 3
2 6 7
214 7
11 12 7 13 176 23 191
样例输出 1
4 8
38 207
提交代码
请先登录后提交
🤖 AI 解题助手
DeepSeek
就绪