#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m,k;
cin>>n>>m>>k;
int arr[m+2];arr[0] = 0-k;
for(int i = 1;i<=m;i++){
cin>>arr[i];
}arr[m+1] = n;
sort(arr,arr+m);
int sum = 0;int z = ((k*2)+1);
for(int i = 1;i<=m;i++){
int u = arr[i]-k;
int r = arr[i-1]+k;
if(((u-r)-1)>0){
int o = ((u-r)-1)/z;
if(((u-r)-1)%z!=0)o++;
sum+=max(o,0);
}
}
int u = n+1;
int r = arr[m]+k;
if(((u-r)-1)>0){
int o = ((u-r)-1)/z;
if(((u-r)-1)%z!=0)o++;
sum+=max(o,0);
}
cout<<sum<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |