#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int n, m, d, a[1000005], b[1000005];
queue<int> dn[1000005];
bool f(int x) {
queue<int> p;
for(int i = 1; i <= n; ++i) {
int o = x;
while(!p.empty() && o > 0) {
if(i - p.front() > d)
return 0;
--o;
p.pop();
}
for(int j = 0; j < b[i]; ++j) {
if(o > 0) {
--o;
continue;
}
p.push(i);
}
}
if(p.size() > 0)
return 0;
return 1;
}
int main() {
cin >> n >> d >> m;
for(int i = 0; i < m; ++i)
cin >> a[i], ++b[a[i]], dn[a[i]].push(i + 1);
f(1);
int lo = 1, hi = 1000005;
while(lo < hi) {
int md = (hi + lo) / 2;
if(f(md))
hi = md;
else
lo = md + 1;
}
int x = lo;
cout << lo << endl;
queue<int> p;
for(int i = 1; i <= n; ++i) {
int o = x;
while(!p.empty() && o > 0) {
--o;
cout << dn[p.front()].front() << " ", dn[p.front()].pop();
p.pop();
}
for(int j = 0; j < b[i]; ++j) {
if(o > 0) {
--o;
cout << dn[i].front() << " ", dn[i].pop();
continue;
}
p.push(i);
}
cout << "0 \n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
48 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Runtime error |
43 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Runtime error |
49 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Runtime error |
47 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Runtime error |
44 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
6 |
Runtime error |
45 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Runtime error |
50 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Runtime error |
45 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
45 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
45 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
11 |
Runtime error |
46 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
12 |
Runtime error |
47 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
13 |
Runtime error |
47 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
14 |
Runtime error |
49 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
15 |
Runtime error |
46 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
16 |
Runtime error |
50 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
17 |
Runtime error |
50 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
18 |
Runtime error |
45 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
19 |
Runtime error |
46 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
20 |
Runtime error |
47 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |