90分AC,10分TLE
代码:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int L, k, n;
cin >> L >> k >> n;
vector<bool> can_park(L + 1, true);
for (int i = 0; i < n; i++) {
int pos;
cin >> pos;
can_park[pos] = false;
}
int count = 0;
for (int i = 1; i <= L - k + 1; i++) {
bool canPark = true;
for (int j = i; j < i + k; j++) {
if (!can_park[j]) {
canPark = false;
break;
}
}
if (canPark) {
count++;
i += k - 1;
}
}
cout << count << endl;
return 0;
}