{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eSaruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of \u003ci\u003eR\u003c/i\u003e units, and must be carried by some troop in the army (i.e., palantirs are not allowed to “free float” in mid-air). Help Saruman take control of Middle Earth by determining the minimum number of palantirs needed for Saruman to ensure that each of his minions is within \u003ci\u003eR\u003c/i\u003e units of some palantir.\u003c/p\u003e\u003c/span\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eThe input test file will contain multiple cases. Each test case begins with a single line containing an integer \u003ci\u003eR\u003c/i\u003e, the maximum effective range of all palantirs (where 0 ≤ \u003ci\u003eR\u003c/i\u003e ≤ 1000), and an integer \u003ci\u003en\u003c/i\u003e, the number of troops in Saruman’s army (where 1 ≤ \u003ci\u003en\u003c/i\u003e ≤ 1000). The next line contains n integers, indicating the positions \u003ci\u003ex\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, …, \u003ci\u003ex\u003csub\u003en\u003c/sub\u003e\u003c/i\u003e of each troop (where 0 ≤ \u003ci\u003ex\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ 1000). The end-of-file is marked by a test case with \u003ci\u003eR\u003c/i\u003e \u003d \u003ci\u003en\u003c/i\u003e \u003d −1.\u003c/p\u003e\u003c/span\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, print a single integer indicating the minimum number of palantirs needed.\u003c/p\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\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\u003e0 3\r\n10 20 20\r\n10 7\r\n70 30 1 7 15 20 50\r\n-1 -1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n4\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eIn the first test case, Saruman may place a palantir at positions 10 and 20. Here, note that a single palantir with range 0 can cover both of the troops at position 20.\u003c/p\u003e\u003cp\u003eIn the second test case, Saruman can place palantirs at position 7 (covering troops at 1, 7, and 15), position 20 (covering positions 20 and 30), position 50, and position 70. Here, note that palantirs must be distributed among troops and are not allowed to “free float.” Thus, Saruman cannot place a palantir at position 60 to cover the troops at positions 50 and 70.\u003c/p\u003e\u003c/span\u003e"}}]}