#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 1e6 + 69;
int n, d, m, a[N], b[N];
vector<int> g[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;
vector<int> c;
c.push_back(0);
for (int i = 1;i <= m;i++) {
cin >> a[i];
g[a[i]].push_back(i);
c.push_back(a[i]);
}
sort(c.begin(), c.end());
int l = 1, r = m, ans = 0;
auto check = [&](int mid) {
int t = 0;
for (int i = 1;i <= m;i++)
b[i] = (i + mid - 1) / mid;
for (int i = 1;i <= m;i++) {
t += 1;
if (t > mid) {
b[i] = b[i - 1] + 1;
t = 1;
}
if (b[i] < c[i]) {
b[i] = c[i];
t = 1;
}
}
for (int i = 1;i <= m;i++) {
if (c[i] + d < b[i])
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3134 ms |
65536 KB |
Time limit exceeded |
2 |
Execution timed out |
3455 ms |
65536 KB |
Time limit exceeded |
3 |
Execution timed out |
3042 ms |
65536 KB |
Time limit exceeded |
4 |
Execution timed out |
3034 ms |
65536 KB |
Time limit exceeded |
5 |
Runtime error |
902 ms |
65528 KB |
Memory limit exceeded |
6 |
Runtime error |
764 ms |
58776 KB |
Memory limit exceeded |
7 |
Runtime error |
650 ms |
53964 KB |
Memory limit exceeded |
8 |
Runtime error |
582 ms |
50484 KB |
Memory limit exceeded |
9 |
Execution timed out |
3080 ms |
65536 KB |
Time limit exceeded |
10 |
Execution timed out |
3032 ms |
65536 KB |
Time limit exceeded |
11 |
Incorrect |
41 ms |
25800 KB |
Expected EOLN |
12 |
Incorrect |
68 ms |
27716 KB |
Expected EOLN |
13 |
Incorrect |
102 ms |
30448 KB |
Expected EOLN |
14 |
Incorrect |
139 ms |
31932 KB |
Expected EOLN |
15 |
Runtime error |
153 ms |
35008 KB |
Memory limit exceeded |
16 |
Runtime error |
213 ms |
37896 KB |
Memory limit exceeded |
17 |
Runtime error |
237 ms |
40764 KB |
Memory limit exceeded |
18 |
Runtime error |
556 ms |
55792 KB |
Memory limit exceeded |
19 |
Runtime error |
918 ms |
65536 KB |
Execution killed with signal 9 |
20 |
Runtime error |
242 ms |
40888 KB |
Memory limit exceeded |