#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ar array
const int INF = 1e15;
const int MOD = 1e9+7;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, d, m; cin>>n>>d>>m;
vector<ar<int,2>> a(m);
for (int i = 0; i < m; i++) {
cin>>a[i][0]; a[i][1] = i+1;
}
sort(a.begin(), a.end());
auto check = [&](int x) {
if ((m+x-1)/x >= n) return false;
vector<int> time(x, 0);
for (int i = 0; i < m; i++) {
if (time[i % x] - a[i][0] > d) return false;
time[i % x] = max(time[i % x], a[i][0]) + 1;
}
return true;
};
int lo = 1, hi = m, mid, x;
while (lo <= hi) {
mid = (lo + hi)>>1;
if (check(mid)) {
hi = mid-1; x = mid;
} else lo = mid+1;
}
cout<<x<<"\n";
for (int i = 0, j = 0; i < n; i++) {
for (int k = j; j < min(k+x,m); j++) cout<<a[j][1]<<" ";
cout<<"0\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
2916 KB |
Output is correct |
2 |
Correct |
32 ms |
2916 KB |
Output is correct |
3 |
Correct |
32 ms |
2916 KB |
Output is correct |
4 |
Correct |
32 ms |
2916 KB |
Output is correct |
5 |
Correct |
33 ms |
2916 KB |
Output is correct |
6 |
Correct |
33 ms |
2916 KB |
Output is correct |
7 |
Correct |
32 ms |
2916 KB |
Output is correct |
8 |
Correct |
33 ms |
2916 KB |
Output is correct |
9 |
Correct |
43 ms |
2916 KB |
Output is correct |
10 |
Correct |
43 ms |
2916 KB |
Output is correct |
11 |
Correct |
40 ms |
2660 KB |
Output is correct |
12 |
Incorrect |
81 ms |
5208 KB |
Output isn't correct |
13 |
Correct |
124 ms |
7612 KB |
Output is correct |
14 |
Incorrect |
173 ms |
10220 KB |
Output isn't correct |
15 |
Correct |
214 ms |
12612 KB |
Output is correct |
16 |
Correct |
260 ms |
15036 KB |
Output is correct |
17 |
Correct |
306 ms |
17440 KB |
Output is correct |
18 |
Correct |
389 ms |
20016 KB |
Output is correct |
19 |
Correct |
413 ms |
22688 KB |
Output is correct |
20 |
Correct |
305 ms |
17440 KB |
Output is correct |