#include <bits/stdc++.h>
using namespace std;
bitset<2001> bs;
int main()
{
int n; cin >> n;
int m; cin >> m;
int k; cin >> k;
vector<int> lights(m);
for(int i = 0; i < m; i++)
{
cin >> lights[i];
for(int j = max(lights[i]-k, 1); j <= min(lights[i]+k, n); j++){bs[j] = 1;}
}
int ans = 0;
for(int i = 1; i <= n; i++)
{
if(!bs[i])
{
ans++;
int val = i+k;
for(int j = max(val-k, 1); j <= min(val+k, n); j++){bs[j] = 1;}
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |