#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 25;
int n, d, m;
int a[MAXN];
bool check (int x) {
bool flag = 1;
int ptr = 1;
for (int day = 1; day <= n; day++) {
int cnt = 0;
while (ptr <= m && a[ptr] >= day && cnt + 1 <= x) {
flag &= day <= a[ptr] + d;
ptr++; cnt++;
}
}
flag &= ptr == m + 1;
return flag;
}
void cringe () {
for (int i = 1; i <= n; i++) cout << 0 << endl;
}
int main () {
ios::sync_with_stdio(0); cin.tie(0);
//freopen("rand", "r", stdin);
cin >> n >> d >> m;
for (int i = 1; i <= m; i++) cin >> a[i];
sort(a + 1, a + m + 1);
int l = 1, r = m - 1, ans = m;
while (l <= r) {
int mid = (l + r) >> 1;
if (check(mid)) {
r = mid - 1; ans = mid;
} else {
l = mid + 1;
}
}
cout << ans << '\n';
cringe();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
2784 KB |
Output isn't correct |
2 |
Incorrect |
18 ms |
2908 KB |
Output isn't correct |
3 |
Incorrect |
18 ms |
2904 KB |
Output isn't correct |
4 |
Incorrect |
18 ms |
3008 KB |
Output isn't correct |
5 |
Incorrect |
26 ms |
2904 KB |
Output isn't correct |
6 |
Incorrect |
18 ms |
2896 KB |
Output isn't correct |
7 |
Incorrect |
27 ms |
2908 KB |
Output isn't correct |
8 |
Incorrect |
18 ms |
2904 KB |
Output isn't correct |
9 |
Incorrect |
129 ms |
3204 KB |
Output isn't correct |
10 |
Incorrect |
163 ms |
3040 KB |
Output isn't correct |
11 |
Incorrect |
13 ms |
2908 KB |
Output isn't correct |
12 |
Incorrect |
31 ms |
3164 KB |
Output isn't correct |
13 |
Incorrect |
32 ms |
3180 KB |
Output isn't correct |
14 |
Incorrect |
66 ms |
3200 KB |
Output isn't correct |
15 |
Incorrect |
73 ms |
3196 KB |
Output isn't correct |
16 |
Incorrect |
82 ms |
3160 KB |
Output isn't correct |
17 |
Incorrect |
101 ms |
3952 KB |
Output isn't correct |
18 |
Incorrect |
91 ms |
3924 KB |
Output isn't correct |
19 |
Incorrect |
204 ms |
4496 KB |
Output isn't correct |
20 |
Incorrect |
94 ms |
3692 KB |
Output isn't correct |