#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
int n, d, m;
cin >> n >> d >> m;
int a[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 |
1026 ms |
43120 KB |
Time limit exceeded |
2 |
Execution timed out |
1042 ms |
44720 KB |
Time limit exceeded |
3 |
Execution timed out |
1024 ms |
45356 KB |
Time limit exceeded |
4 |
Execution timed out |
1057 ms |
43928 KB |
Time limit exceeded |
5 |
Execution timed out |
1072 ms |
44928 KB |
Time limit exceeded |
6 |
Execution timed out |
1051 ms |
42828 KB |
Time limit exceeded |
7 |
Execution timed out |
1098 ms |
44052 KB |
Time limit exceeded |
8 |
Execution timed out |
1035 ms |
44460 KB |
Time limit exceeded |
9 |
Execution timed out |
1087 ms |
45192 KB |
Time limit exceeded |
10 |
Execution timed out |
1064 ms |
43112 KB |
Time limit exceeded |
11 |
Incorrect |
20 ms |
1224 KB |
Expected EOLN |
12 |
Incorrect |
31 ms |
1880 KB |
Expected EOLN |
13 |
Incorrect |
49 ms |
3040 KB |
Expected EOLN |
14 |
Incorrect |
71 ms |
3920 KB |
Expected EOLN |
15 |
Incorrect |
83 ms |
4432 KB |
Expected EOLN |
16 |
Incorrect |
118 ms |
5588 KB |
Expected EOLN |
17 |
Incorrect |
124 ms |
6568 KB |
Expected EOLN |
18 |
Incorrect |
475 ms |
21072 KB |
Expected EOLN |
19 |
Execution timed out |
1036 ms |
44112 KB |
Time limit exceeded |
20 |
Incorrect |
124 ms |
6476 KB |
Expected EOLN |