#include <iostream>
#include <algorithm>
#include <tuple>
using namespace std;
#define pi pair<int, int>
#define f first
#define s second
int n, d, m;
int j[100001];
pi jd[1000000];
bool q(int x) {
int cd = 0;
int cj[100001];
for (int i = 1; i <= n; ++i) {
cj[i] = j[i];
}
for (int i = 1; i <= n; ++i) {
if (cj[i] % x == 0 || cj[i] < x) {
if (cd + cj[i] / x >= d) return false;
cd += cj[i] / x;
}
else {
if (cd + cj[i] / x + 1 >= d) return false;
cd += cj[i] / x + 1;
}
if (i != n) {
if (cj[i + 1] >= x - (cj[i] - x * (cj[i] / x)))
cj[i + 1] -= x - (cj[i] - x * (cj[i] / x));
else cj[i + 1] = 0;
}
}
return true;
}
int main() {
cin >> n >> d >> m;
for (int i = 0; i < m; ++i) {
int a; cin >> a;
++j[a];
jd[i] = {a, i + 1};
}
sort(jd, jd + m);
int l = 0, r = 1000000;
for (r ++; l < r; ) {
int m = l + (r - l) / 2;
if (q(m)) r = m;
else l = m + 1;
}
cout << l << endl;
for (int i = 0; i < m; i += l) {
for (int j = 0; j < l; ++j) {
cout << jd[i + j].s << ' ';
}
cout << 0 << endl;
}
for (int i = 0; i < d; ++i) cout << 0 << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
1604 KB |
Output isn't correct |
2 |
Incorrect |
35 ms |
1648 KB |
Output isn't correct |
3 |
Incorrect |
35 ms |
1640 KB |
Output isn't correct |
4 |
Incorrect |
36 ms |
1640 KB |
Output isn't correct |
5 |
Incorrect |
36 ms |
1668 KB |
Output isn't correct |
6 |
Incorrect |
35 ms |
1696 KB |
Output isn't correct |
7 |
Incorrect |
36 ms |
1600 KB |
Output isn't correct |
8 |
Incorrect |
35 ms |
1604 KB |
Output isn't correct |
9 |
Incorrect |
56 ms |
1988 KB |
Output isn't correct |
10 |
Incorrect |
56 ms |
1968 KB |
Output isn't correct |
11 |
Incorrect |
49 ms |
1604 KB |
Output isn't correct |
12 |
Incorrect |
94 ms |
3044 KB |
Output isn't correct |
13 |
Incorrect |
143 ms |
4564 KB |
Output isn't correct |
14 |
Incorrect |
217 ms |
6224 KB |
Output isn't correct |
15 |
Incorrect |
237 ms |
7516 KB |
Output isn't correct |
16 |
Incorrect |
316 ms |
9172 KB |
Output isn't correct |
17 |
Incorrect |
371 ms |
10596 KB |
Output isn't correct |
18 |
Incorrect |
386 ms |
12096 KB |
Output isn't correct |
19 |
Incorrect |
442 ms |
13892 KB |
Output isn't correct |
20 |
Incorrect |
367 ms |
10692 KB |
Output isn't correct |