#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<set>
using namespace std;
int main(){
int n, m, k; cin>>n>>m>>k;
vector<int> lights(m);
for(auto &el: lights){
cin>>el; el--;
}
lights.push_back(n+k);
vector<pair<int,int>> intervals;
int last = 0;
for(auto &pos: lights){
int cstart = pos - k;
int cend = pos + k + 1;
if(cstart > last){
intervals.push_back({last, cstart-1});
}
last = cend;
}
int span = 2*k+1;
int answer = 0;
for(auto &p: intervals){
answer += (p.second - p.first + 1) / span;
if((p.second - p.first + 1) % span != 0) answer++;
}
cout<<answer;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |