#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define r first
#define c second
#define all(x) x.begin(), x.end()
ostream& operator << (ostream& os, pair<int, int> a) {
return os << a.first << " : " << a.second;
}
#define endl '\n'
#define db(val) "["#val" = "<<(val)<<"] "
#define cntbit(x) __builtin_popcount(x)
const int N = 1000 + 5;
const int iINF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
int n, m, k;
int a[N];
int main() {
#ifdef CHUNGDINH
freopen("main.inp","r",stdin);
//freopen("main.out","w",stdout);
#endif
int res = 0;
cin >> n >> m >> k;
for (int i = 1; i <= m; i++) cin >> a[i];
sort(a + 1, a + 1 + m);
int last = 0;
for (int i = 1; i <= m; i++) {
if (a[i] - k > last + 1) res += ceil(double(a[i] - k - 1 - (last + 1) + 1) / double(2 * k + 1));
last = a[i] + k;
}
if (last < n) res += ceil(double(n - (last + 1) + 1) / double(2 * k + 1));
cout << res;
}
/*
Array bounds *
long long vs int
Garbage value
Sometimes, VNOI views "arrays out of bounds" as "wrong answer"
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
296 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |