You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
559 B
C++
25 lines
559 B
C++
#include <cstdio>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
int a[1011];
|
|
int main()
|
|
{
|
|
int r, n;
|
|
while (scanf("%d%d", &r, &n), ~(r & n))
|
|
{
|
|
for (int i = 0; i < n; i++)
|
|
scanf("%d", a + i);
|
|
sort(a, a + n);
|
|
int i = 0, res = 0;
|
|
while (i < n)
|
|
{
|
|
int s = a[i++];
|
|
while (i < n && a[i] - r <= s) i++;
|
|
int p = a[i - 1];
|
|
while (i < n && a[i] <= p + r) i++;
|
|
res++;
|
|
}
|
|
printf("%d\n", res);
|
|
}
|
|
return 0;
|
|
} |