#include <bits/stdc++.h>
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 |
36 ms |
1732 KB |
Output isn't correct |
2 |
Incorrect |
36 ms |
1792 KB |
Output isn't correct |
3 |
Incorrect |
41 ms |
1700 KB |
Output isn't correct |
4 |
Incorrect |
37 ms |
1728 KB |
Output isn't correct |
5 |
Incorrect |
36 ms |
1804 KB |
Output isn't correct |
6 |
Incorrect |
44 ms |
1808 KB |
Output isn't correct |
7 |
Incorrect |
36 ms |
1752 KB |
Output isn't correct |
8 |
Incorrect |
36 ms |
1700 KB |
Output isn't correct |
9 |
Incorrect |
56 ms |
2088 KB |
Output isn't correct |
10 |
Incorrect |
59 ms |
2108 KB |
Output isn't correct |
11 |
Incorrect |
48 ms |
1696 KB |
Output isn't correct |
12 |
Incorrect |
95 ms |
3260 KB |
Output isn't correct |
13 |
Incorrect |
155 ms |
4680 KB |
Output isn't correct |
14 |
Incorrect |
230 ms |
6260 KB |
Output isn't correct |
15 |
Incorrect |
235 ms |
7648 KB |
Output isn't correct |
16 |
Incorrect |
331 ms |
9256 KB |
Output isn't correct |
17 |
Incorrect |
388 ms |
10792 KB |
Output isn't correct |
18 |
Incorrect |
381 ms |
12164 KB |
Output isn't correct |
19 |
Incorrect |
449 ms |
14000 KB |
Output isn't correct |
20 |
Incorrect |
408 ms |
10820 KB |
Output isn't correct |