{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv style\u003d\"width:25.00%\" class\u003d\"illustration\"\u003e\n \u003cimg src\u003d\"CDN_BASE_URL/3d58cf9ef960e5e106ad135bb992211e?v\u003d1715656979\" alt\u003d\"/problems/ants/file/statement/en/img-0001.jpg\" class\u003d\"illustration\"\u003e\n\n \n \u003c/div\u003e\n\n \u003cp\u003eAn army of ants walk on a horizontal pole of length\n \u003cspan class\u003d\"tex2jax_process\"\u003e$l$\u003c/span\u003e cm, each with a\n constant speed of \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e\n cm/s. When a walking ant reaches an end of the pole, it\n immediatelly falls off it. When two ants meet they turn back\n and start walking in opposite directions. We know the original\n positions of ants on the pole, unfortunately, we do not know\n the directions in which the ants are walking. Your task is to\n compute the earliest and the latest possible times needed for\n all ants to fall off the pole.\u003c/p\u003e\n\n \u003ch2\u003eInput\u003c/h2\u003e\n\n \u003cp\u003eThe first line of input contains one integer giving the\n number of cases that follow, at most 100. The data for each\n case start with two integer numbers: the length \u003cspan class\u003d\"tex2jax_process\"\u003e$l$\u003c/span\u003e of the pole (in cm) and\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e, the number of ants\n residing on the pole. These two numbers are followed by\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e integers giving the\n position of each ant on the pole as the distance measured from\n the left end of the pole, in no particular order. All input\n integers are between \u003cspan class\u003d\"tex2jax_process\"\u003e$0$\u003c/span\u003e\n and \u003cspan class\u003d\"tex2jax_process\"\u003e$1\\, 000\\, 000$\u003c/span\u003e and\n they are separated by whitespace.\u003c/p\u003e\n\n \u003ch2\u003eOutput\u003c/h2\u003e\n\n \u003cp\u003eFor each case of input, output two numbers separated by a\n single space. The first number is the earliest possible time\n when all ants fall off the pole (if the directions of their\n walks are chosen appropriately) and the second number is the\n latest possible such time.\u003c/p\u003e\n\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n10 3\n2 6 7\n214 7\n11 12 7 13\n176 23 191\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4 8\n38 207\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}