#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 1e6 + 69;
int n, m, d, a[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
cin >> n >> d >> m;
for (int i = 0;i < m;i++)
cin >> a[i];
sort(a, a + m);
int l = 1, r = m, ans = 0;
auto check = [&](int mid) {
int t = 0, s = 1;
for (int i = 0;i < m;i++) {
t += 1;
if (t > mid) {
s += 1;
t = 1;
}
if (s < a[i]) {
s = a[i];
t = 1;
}
if (a[i] + d < s)
return false;
}
return true;
};
while (l <= r) {
int mid = (l + r) / 2;
if (check(mid)) {
ans = mid;
r = mid - 1;
}
else
l = mid + 1;
}
cout << ans << '\n';
for (int i = 1;i <= n;i++) {
if (i > n - d) {
cout << 0 << '\n';
continue;
}
for (int j = 1;j <= ans + 1;j++)
cout << 0 << ' ';
cout << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
45764 KB |
Time limit exceeded |
2 |
Execution timed out |
1092 ms |
45932 KB |
Time limit exceeded |
3 |
Execution timed out |
1067 ms |
45996 KB |
Time limit exceeded |
4 |
Execution timed out |
1027 ms |
43352 KB |
Time limit exceeded |
5 |
Execution timed out |
1050 ms |
43296 KB |
Time limit exceeded |
6 |
Execution timed out |
1048 ms |
43092 KB |
Time limit exceeded |
7 |
Execution timed out |
1040 ms |
43696 KB |
Time limit exceeded |
8 |
Execution timed out |
1041 ms |
43344 KB |
Time limit exceeded |
9 |
Execution timed out |
1052 ms |
44468 KB |
Time limit exceeded |
10 |
Execution timed out |
1054 ms |
45972 KB |
Time limit exceeded |
11 |
Incorrect |
17 ms |
856 KB |
Expected EOLN |
12 |
Incorrect |
35 ms |
1620 KB |
Expected EOLN |
13 |
Incorrect |
48 ms |
2128 KB |
Expected EOLN |
14 |
Incorrect |
70 ms |
2696 KB |
Expected EOLN |
15 |
Incorrect |
80 ms |
3416 KB |
Expected EOLN |
16 |
Incorrect |
111 ms |
4072 KB |
Expected EOLN |
17 |
Incorrect |
123 ms |
4524 KB |
Expected EOLN |
18 |
Incorrect |
452 ms |
19404 KB |
Expected EOLN |
19 |
Execution timed out |
1022 ms |
43344 KB |
Time limit exceeded |
20 |
Incorrect |
124 ms |
4436 KB |
Expected EOLN |