#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void solve() {
int n, d, m; cin >> n >> d >> m;
vector<pair<int, int > > v;
for (int i = 0; i < m; ++i) {
int x; cin >> x;
v.push_back({x, i + 1});
}
sort(v.begin(), v.end());
// for (auto [u, x] : v) cerr << u << " " << x << endl;
// cerr << "----------------------------------------------\n";
int lo = 1, hi = m;
vector<int> ans[n + 1], final[n + 1];
auto test = [&] (int numOfMachine) {
for (int i = 1; i <= n; ++i) ans[i].clear();
int cur = 0, tot = 0, day = 0;
for (int i = 0; i < m; ) {
int j = i;
if (day != v[i].first) cur = 0;
day = max(day, v[i].first);
while (j < m and v[i].first == v[j].first) {
if (day - v[j].first > d) return false;
ans[day].push_back(v[j].second);
cur++;
tot++;
j++;
// if (numOfMachine == 1) cerr << "#" << day << " " << tot << " " << cur << endl;
if (cur == numOfMachine) cur = 0, day++;
}
i = j;
}
return tot == m;
};
while (lo < hi) {
int mid = lo + (hi - lo) / 2;
if (test(mid)) {
hi = mid;
for (int i = 1; i <= n; ++i) {
final[i].clear();
for (auto u : ans[i]) final[i].push_back(u);
final[i].push_back(0);
}
}
else lo = mid + 1;
}
cout << hi << "\n";
for (int i = 1; i <= n; ++i) {
for (auto u : final[i]) cout << u << " ";
cout << "\n";
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
3572 KB |
Expected EOLN |
2 |
Incorrect |
31 ms |
3632 KB |
Expected EOLN |
3 |
Incorrect |
28 ms |
3656 KB |
Expected EOLN |
4 |
Incorrect |
28 ms |
3604 KB |
Expected EOLN |
5 |
Incorrect |
27 ms |
3596 KB |
Expected EOLN |
6 |
Incorrect |
29 ms |
3624 KB |
Expected EOLN |
7 |
Incorrect |
29 ms |
3652 KB |
Expected EOLN |
8 |
Incorrect |
29 ms |
3544 KB |
Expected EOLN |
9 |
Incorrect |
56 ms |
11120 KB |
Expected EOLN |
10 |
Incorrect |
60 ms |
11080 KB |
Output isn't correct |
11 |
Incorrect |
34 ms |
3052 KB |
Output isn't correct |
12 |
Incorrect |
68 ms |
5704 KB |
Output isn't correct |
13 |
Incorrect |
132 ms |
9028 KB |
Output isn't correct |
14 |
Incorrect |
165 ms |
12472 KB |
Output isn't correct |
15 |
Incorrect |
170 ms |
13940 KB |
Expected EOLN |
16 |
Incorrect |
249 ms |
19232 KB |
Output isn't correct |
17 |
Incorrect |
261 ms |
22544 KB |
Output isn't correct |
18 |
Incorrect |
290 ms |
21448 KB |
Output isn't correct |
19 |
Incorrect |
346 ms |
30300 KB |
Output isn't correct |
20 |
Incorrect |
282 ms |
22540 KB |
Output isn't correct |