#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
vector<vector<int>> J(n);
for(int i=0; i<m; i++) {
int c; cin >> c;
J[c-1].push_back(i+1);
}
int lo=0, hi=m;
while(lo < hi) {
int mid = (lo + hi) / 2;
int t = 0;
int rem=mid;
bool works=true;
for(int i=0; i<n && works; i++) {
int count = J[i].size();
count -= rem;
t++;
rem=mid;
if(count<0) continue;
while(count>0) {
count-=mid;
if(count<0) rem=-count;
else t++;
}
if(t-i>d) works=false;
}
if(works) hi = mid;
else lo = mid+1;
}
cout << lo << "\n";
int count=0;
int acc=0;
for(int i=0; i<n; i++) {
for(int j : J[i]) {
if(count>=lo) {
cout << 0 << "\n" << j << " ";
acc++;
count=1;
}
else {
cout << j << " ";
count++;
}
}
if(acc<=i) {
cout << 0 << "\n";
count=0;
acc++;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
1696 KB |
Output isn't correct |
2 |
Incorrect |
14 ms |
1644 KB |
Output isn't correct |
3 |
Incorrect |
16 ms |
1620 KB |
Output isn't correct |
4 |
Incorrect |
14 ms |
1624 KB |
Output isn't correct |
5 |
Incorrect |
15 ms |
1668 KB |
Output isn't correct |
6 |
Incorrect |
14 ms |
1708 KB |
Output isn't correct |
7 |
Incorrect |
14 ms |
1600 KB |
Output isn't correct |
8 |
Incorrect |
14 ms |
1620 KB |
Output isn't correct |
9 |
Correct |
23 ms |
4116 KB |
Output is correct |
10 |
Correct |
22 ms |
4060 KB |
Output is correct |
11 |
Correct |
15 ms |
1480 KB |
Output is correct |
12 |
Incorrect |
29 ms |
2636 KB |
Output isn't correct |
13 |
Correct |
43 ms |
4556 KB |
Output is correct |
14 |
Incorrect |
72 ms |
5904 KB |
Output isn't correct |
15 |
Correct |
80 ms |
6688 KB |
Output is correct |
16 |
Incorrect |
103 ms |
8552 KB |
Output isn't correct |
17 |
Correct |
122 ms |
10444 KB |
Output is correct |
18 |
Correct |
116 ms |
10564 KB |
Output is correct |
19 |
Correct |
135 ms |
13552 KB |
Output is correct |
20 |
Correct |
119 ms |
10420 KB |
Output is correct |