#include<bits/stdc++.h>
[[maybe_unused]] typedef long long ll;
[[maybe_unused]] const int N = (int) 1e6 + 20;
[[maybe_unused]] const int mod = (int) 1e9 + 7;
[[maybe_unused]] char endl = '\n';
[[maybe_unused]] char space = ' ';
[[maybe_unused]] const int off = 1 << 18;
void Run();
int main()
{
Run();
//in
int t = 1;
// std::cin >> t;
while (t--) {
int n,d,m;
std::cin >> n >> d >> m;
std::set<std::pair<int,int>,std::greater<>> s;
for (int i = 1; i <= m; ++i) {
int x;
std::cin >> x;
s.insert({x,i});
}
//ops
std::vector<std::queue<int>> days(n + 1);
std::vector<int> rm(m,n + 1);//pos of rightmost day wth i as num of jobs
for (const auto &[u,v]: s) {
int low = int(std::lower_bound(rm.begin(), rm.end(),u) - rm.begin());
rm[low] = std::min(rm[low], u + d);
days[rm[low]--].push(v);
if (rm[low + 1] == n + 1) {
rm[low + 1] = rm[low] + 1;
}
}
//out
int max = INT_MIN;
for (const auto &item: days) {
max = std::max((int)item.size(),max);
}
std::cout << max << endl;
for (int i = 1; i <= n; ++i) {
while(!days[i].empty()) {
std::cout << days[i].front() << space;
days[i].pop();
}
std::cout << 0;
if (i != n) {
std::cout << endl;
}
}
}
return 0;
}
void Run(){
std::ios_base::sync_with_stdio(false);std::cin.tie(nullptr);std::cout.tie(nullptr);
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
#endif
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
13072 KB |
Output is correct |
2 |
Correct |
45 ms |
13096 KB |
Output is correct |
3 |
Correct |
45 ms |
13140 KB |
Output is correct |
4 |
Correct |
45 ms |
13084 KB |
Output is correct |
5 |
Correct |
44 ms |
13056 KB |
Output is correct |
6 |
Correct |
44 ms |
13132 KB |
Output is correct |
7 |
Correct |
43 ms |
13100 KB |
Output is correct |
8 |
Correct |
45 ms |
13136 KB |
Output is correct |
9 |
Runtime error |
57 ms |
65536 KB |
Execution killed with signal 9 |
10 |
Runtime error |
56 ms |
65536 KB |
Execution killed with signal 9 |
11 |
Incorrect |
51 ms |
6564 KB |
Output isn't correct |
12 |
Incorrect |
130 ms |
12812 KB |
Output isn't correct |
13 |
Incorrect |
226 ms |
19180 KB |
Output isn't correct |
14 |
Incorrect |
436 ms |
30040 KB |
Output isn't correct |
15 |
Incorrect |
423 ms |
31440 KB |
Output isn't correct |
16 |
Runtime error |
681 ms |
41688 KB |
Memory limit exceeded |
17 |
Runtime error |
838 ms |
47400 KB |
Memory limit exceeded |
18 |
Runtime error |
753 ms |
56440 KB |
Memory limit exceeded |
19 |
Runtime error |
549 ms |
65536 KB |
Execution killed with signal 9 |
20 |
Runtime error |
828 ms |
47440 KB |
Memory limit exceeded |