#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define MAXN 100005
int n, d, m, arr[MAXN], res = 0;
vector<pair<int, int>> req;
int main(){
cin >> n >> d >> m;
FOR(i, 1, n) arr[i] = 0;
FOR(i, 1, m){
int x; cin >> x;
arr[x]++;
req.push_back({x, i});
}
sort(req.begin(), req.end());
multiset<int> s; s.insert(0);
FOR(i, 1, 1 + d) s.insert(0);
FOR(i, 1, n){
res = max(res, *s.rbegin());
s.erase(s.find(*s.rbegin()));
FOR(j, 1, arr[i]){
int k = *s.begin();
s.erase(s.begin());
s.insert(k + 1);
}
s.insert(0);
}
res = max(res, *s.rbegin());
cout << res << endl;
/*int k = -1;
FOR(i, 1, n){
int j = 1;
while(j <= res && (k + 1 < m) && (req[k + 1].first <= i && req[k + 1].first + d <= i)){
cout << req[k + 1].second << " ";
j++, k++;
}
cout << "0" << endl;
}*/
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
1488 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
18 ms |
1492 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
15 ms |
1492 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
16 ms |
1492 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
15 ms |
1492 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
15 ms |
1492 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
15 ms |
1488 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
16 ms |
1488 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
25 ms |
2004 KB |
Output isn't correct |
10 |
Incorrect |
23 ms |
1756 KB |
Output isn't correct |
11 |
Incorrect |
28 ms |
1492 KB |
Output isn't correct |
12 |
Incorrect |
45 ms |
2512 KB |
Output isn't correct |
13 |
Incorrect |
68 ms |
6332 KB |
Output isn't correct |
14 |
Incorrect |
105 ms |
5808 KB |
Output isn't correct |
15 |
Incorrect |
114 ms |
6076 KB |
Output isn't correct |
16 |
Incorrect |
170 ms |
9144 KB |
Output isn't correct |
17 |
Incorrect |
173 ms |
8888 KB |
Output isn't correct |
18 |
Incorrect |
183 ms |
10420 KB |
Output isn't correct |
19 |
Incorrect |
203 ms |
9400 KB |
Output isn't correct |
20 |
Incorrect |
175 ms |
10420 KB |
Output isn't correct |