区间覆盖点,从左到右贪心枚举即可
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
namespace
{
int R, n;
vector<int> V;
void solve()
{
sort(V.begin(), V.end());
size_t i = 0;
int res = 0;
while (i < V.size())
{
res++;
int d = V[i] + R;
while (i < V.size() && V[i] <= d)
i++;
d = V[i - 1] + R;
while (i < V.size() && V[i] <= d)
i++;
}
printf("%d\n", res);
}
}
int main()
{
while (scanf("%d %d", &R, &n), R != -1)
{
V.clear();
int temp;
while (n--)
{
scanf("%d", &temp);
V.push_back(temp);
}
solve();
}
return 0;
}