#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;
int L[1003];
int main(){
int N,M,K,P,z,z2,br=0;
cin >> N >> M >> K;
//K+=1;
for (int i=0;i<M;i++){
cin >> P;
P-=1;
z=P-K;
z2=P+K+1;
if (z<0) z=0;
if (z2>N) z2=N;
for (int j=z;j<z2;j++){
L[j]=1;
}
}
//for(int i=0; i<N;i++) cout << L[i] << " ";
//cout << "\n";
for (int i=0;i<N;i++){
if (L[i]==0){
P=i+K;
z=P-K;
z2=P+K+1;
if (z<0) z=0;
if (z2>N) z2=N;
for (int j=z;j<z2;j++){
L[j]=1;
}
br+=1;
/*cout << br << ": ";
for(int i=0; i<N;i++) cout << L[i] << " ";
cout << "\n";*/
}
}
//for(int i=0; i<N;i++) cout << L[i] << " ";
//cout << "\n";
cout << br;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |