poj 3069

#include <iostream>
#include <algorithm>

int r, n;
int points[1001];

using namespace std;

int main() {
	
	while(~(scanf("%d%d", &r, &n))) {
		
		if(r == -1 && n == -1)	break;
		
		for(int i=0; i<n; i++)
			cin >> points[i];
			
		sort(points, points+n);
		
		int position = 0, ans = 0, point;
		while(position < n) {
			point = points[position++];
			
			while(position < n && points[position] <= point+r)	position++;
			
			point = points[position-1];
			
			while(position < n && points[position] <= point+r)	position++;
			
			ans ++;
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

posted @ 2016-06-20 16:42  StevenLuke  阅读(87)  评论(0编辑  收藏  举报