You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.6 KiB

2 years ago
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int r, n, X[1100];
int ans;
int main() {
#ifndef ONLINE_JUDGE
freopen("POJ3069.in", "r", stdin);
#endif
while (cin >> r >> n && ~r && ~n) {
ans = 0;
for (int i = 0; i < n; i++) cin >> X[i];
sort(X, X + n);
int i = 0;
while (i < n) {
int s = X[i++]; // s:没有被覆盖的最左边点的位置
while (i < n && X[i] <= s + r) i++; // 找到无法覆盖的点
int p = X[i - 1]; // 新加上标注点的位置
while (i < n && X[i] <= p + r) i++; // 将此点右侧,所有可覆盖的点走完
ans++;
/*
Q:while?while
使
R退
R
while~
*/
}
printf("%d\n", ans);
}
return 0;
}