#include<bits/stdc++.h>
using namespace std;
map<int, set<int>> pos;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
5712 KB |
Output isn't correct |
2 |
Incorrect |
38 ms |
5712 KB |
Output isn't correct |
3 |
Incorrect |
39 ms |
5712 KB |
Output isn't correct |
4 |
Incorrect |
38 ms |
5712 KB |
Output isn't correct |
5 |
Incorrect |
38 ms |
5720 KB |
Output isn't correct |
6 |
Incorrect |
38 ms |
5724 KB |
Output isn't correct |
7 |
Incorrect |
42 ms |
5716 KB |
Output isn't correct |
8 |
Incorrect |
38 ms |
5724 KB |
Output isn't correct |
9 |
Incorrect |
47 ms |
5896 KB |
Output isn't correct |
10 |
Incorrect |
45 ms |
5888 KB |
Output isn't correct |
11 |
Correct |
66 ms |
5776 KB |
Output is correct |
12 |
Correct |
124 ms |
11056 KB |
Output is correct |
13 |
Correct |
201 ms |
16608 KB |
Output is correct |
14 |
Correct |
388 ms |
23424 KB |
Output is correct |
15 |
Correct |
346 ms |
27476 KB |
Output is correct |
16 |
Runtime error |
583 ms |
34480 KB |
Memory limit exceeded |
17 |
Runtime error |
685 ms |
39844 KB |
Memory limit exceeded |
18 |
Runtime error |
638 ms |
44144 KB |
Memory limit exceeded |
19 |
Runtime error |
709 ms |
49784 KB |
Memory limit exceeded |
20 |
Runtime error |
669 ms |
40020 KB |
Memory limit exceeded |