#include <bits/stdc++.h>
#define __gcd() gcd()
#define C int(1e6+7)
#define M int(1e9+7)
#define el '\n'
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
typedef long long ll;
vector<int> res[C],tmp[C];
int main(){
//ios_base::sync_with_stdio(false);
//cin.tie(0);cout.tie(0);
//freopen("","r",stdin);
//freopen("","w",stdout);
int n,d,m;cin>>n>>d>>m;
vector<array<int,2>> a(m);for(int i=0;i<m;i++)cin>>a[i][0],a[i][1] = i;
sort(all(a));
int l=1,r=1e7;
auto check = [&](int mid){
int id = 0,cnt=mid;
for(int i=1;i<=n && id < m;i++){
if(i > a[id][0] + d)return false;
while(id < m && a[id][0] <= i && cnt>=1)tmp[i].pb(a[id][1]+1),cnt--,id++;
cnt = mid;
}
for(int i=1;i<=n;i++)res[i]=tmp[i];
for(int i=1;i<=n;i++)tmp[i].clear();
return true;
};
while(l<r){
int mid=(l+r)/2;
// cout<<'#'<<mid<<el;
if(check(mid))r=mid;
else {
for(int i=1;i<=n;i++)tmp[i].clear();
l= mid+1;
}
}
cout<<r<<el;
for(int i=1;i<=n;i++){
for(auto it:res[i])cout<<it<<' ';
cout<<0<<el;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
42 ms |
50376 KB |
Memory limit exceeded |
2 |
Runtime error |
42 ms |
50452 KB |
Memory limit exceeded |
3 |
Runtime error |
39 ms |
50376 KB |
Memory limit exceeded |
4 |
Runtime error |
39 ms |
50380 KB |
Memory limit exceeded |
5 |
Runtime error |
40 ms |
50404 KB |
Memory limit exceeded |
6 |
Runtime error |
40 ms |
50376 KB |
Memory limit exceeded |
7 |
Runtime error |
39 ms |
50376 KB |
Memory limit exceeded |
8 |
Runtime error |
40 ms |
50376 KB |
Memory limit exceeded |
9 |
Runtime error |
54 ms |
50004 KB |
Memory limit exceeded |
10 |
Runtime error |
55 ms |
50000 KB |
Memory limit exceeded |
11 |
Runtime error |
45 ms |
50008 KB |
Memory limit exceeded |
12 |
Runtime error |
86 ms |
52816 KB |
Memory limit exceeded |
13 |
Runtime error |
121 ms |
56144 KB |
Memory limit exceeded |
14 |
Runtime error |
181 ms |
59984 KB |
Memory limit exceeded |
15 |
Runtime error |
201 ms |
61684 KB |
Memory limit exceeded |
16 |
Runtime error |
259 ms |
65536 KB |
Memory limit exceeded |
17 |
Runtime error |
329 ms |
65536 KB |
Execution killed with signal 9 |
18 |
Runtime error |
312 ms |
65536 KB |
Execution killed with signal 9 |
19 |
Runtime error |
325 ms |
65536 KB |
Execution killed with signal 9 |
20 |
Runtime error |
309 ms |
65536 KB |
Execution killed with signal 9 |