#include<bits/stdc++.h>
using namespace std;
set<int> pos[(int)1e6 + 7];
int main() {
int t = 1;
// cin >> t;
while(t --) {
int n, d, m;
cin >> n >> d >> m;
map<int, int> mp, mp2;
for(int i = 0, x; i < m; i ++) {
cin >> x;
pos[x].insert(i + 1);
mp2[x] ++;
}
int l = 1, r = m;
while(l <= r) {
int mid = (l + r) / 2;
mp = mp2;
for(int i = 1; i <= n && !mp.empty(); i ++) {
int sum = mid;
while(!mp.empty() && mp.begin()->first <= i && sum) {
int x = mp.begin()->first;
int y = mp.begin()->second;
int dd = min(sum, y);
sum -= dd;
if(dd == y) mp.erase(x);
else mp[x] -= dd;
}
}
if(mp.empty()) r = mid - 1;
else l = mid + 1;
}
mp = mp2;
cout << l << '\n';
for(int i = 1; i <= n; i ++) {
int sum = l;
while(!mp.empty() && mp.begin()->first <= i && sum) {
int x = mp.begin()->first;
int y = mp.begin()->second;
int dd = min(sum, y);
sum -= dd;
if(dd == y) mp.erase(x);
else mp[x] -= dd;
while(dd --) {
cout << *pos[x].begin() << ' ';
pos[x].erase(pos[x].begin());
}
}
cout << "0\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
47 ms |
52568 KB |
Memory limit exceeded |
2 |
Runtime error |
48 ms |
52564 KB |
Memory limit exceeded |
3 |
Runtime error |
47 ms |
52664 KB |
Memory limit exceeded |
4 |
Runtime error |
46 ms |
52564 KB |
Memory limit exceeded |
5 |
Runtime error |
47 ms |
52564 KB |
Memory limit exceeded |
6 |
Runtime error |
48 ms |
52548 KB |
Memory limit exceeded |
7 |
Runtime error |
47 ms |
52604 KB |
Memory limit exceeded |
8 |
Runtime error |
46 ms |
52560 KB |
Memory limit exceeded |
9 |
Runtime error |
51 ms |
52820 KB |
Memory limit exceeded |
10 |
Runtime error |
52 ms |
52752 KB |
Memory limit exceeded |
11 |
Runtime error |
58 ms |
52564 KB |
Memory limit exceeded |
12 |
Runtime error |
119 ms |
58112 KB |
Memory limit exceeded |
13 |
Runtime error |
203 ms |
63572 KB |
Memory limit exceeded |
14 |
Runtime error |
202 ms |
65536 KB |
Execution killed with signal 9 |
15 |
Runtime error |
191 ms |
65536 KB |
Execution killed with signal 9 |
16 |
Runtime error |
198 ms |
65536 KB |
Execution killed with signal 9 |
17 |
Runtime error |
238 ms |
65536 KB |
Execution killed with signal 9 |
18 |
Runtime error |
203 ms |
65536 KB |
Execution killed with signal 9 |
19 |
Runtime error |
188 ms |
65536 KB |
Execution killed with signal 9 |
20 |
Runtime error |
215 ms |
65536 KB |
Execution killed with signal 9 |