#include <iostream>
#include <set>
using namespace std;
int main(){
int n, m, k;
cin>>n>>m>>k;
bool lit[n + 1];
for(int i = 1; i <= n; i++)lit[i] = 0;
set <int> unlit;
for(int i = 0; i < m; i++){
int pos; cin>>pos;
int start = max(pos - k, 1), end = min(pos + k, n);
//cout<<start<<" "<<end<<endl;
for(; start <= end; start++)lit[start] = 1;
}
// for(int i = 1; i <= n; i++){
// cout<<lit[i]<<" ";
// }
int ans = 0;
for(int i = 1; i <= n; i++){
if(!lit[i]){
ans++;
int pos = min(i + k, n);
int l = pos - 1, r = pos + 1;
lit[pos] = 1;
for(; l >= pos - k && l >= 1; l--)lit[l] = 1;
for(; r <= n && r <= pos + k; r++)lit[r] = 1;
}
}cout<<ans<<endl;
}
# |
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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |