#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(c) (c).begin(),(c).end()
#define sz(a) ((int)(a.size()))
#define ll long long
#define LINF (ll)1e18
#define INF (int)1e9
#define MINF 0x3F3F3F3F
#define pb push_back
#define fs first
#define sc second
#define mp make_pair
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 2500
#define watch(x) cerr<<#x<<" = "<<(x)<<endl;
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n, m, k, x, c, sol, r;
int arr[MAX];
double d;
int main() {
cin >> n >> m >> k;
for(int i=0;i<m;i++) {
cin >> x;
for(int i=max(1, x-k);i<=x+k;i++) arr[i]++;
}
for(int i=1;i<=n;i++) {
if(arr[i]==0) c++;
if(arr[i] && c) {
d = (double)c/((k<<1)+1);
sol += int(ceil(d));
c = 0;
}
}
d = (double)c/((k<<1)+1);
sol += int(ceil(d));
cout << sol;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
376 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 |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |