#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,d,m;
cin>>n>>d>>m;
vector <pair <int,int> > v;
for(int i=1;i<=m;i++){
int x;cin>>x;
v.pb({x,i});
}
sort(all(v));
int l=0;
int r=1e6+5;
deque <int> day;
while(l+1<r){
int md=(l+r)/2;
for(auto x : v){
day.pb(x.ff);
}
for(int i=1;i<=n;i++){
int cnt=md;
while(day.size()!=0 && day.front()>=i-d && day.front()<=i && cnt>0){
day.pop_front();
cnt--;
}
}
if(day.size()==0)r=md;
else l=md;
while(!day.empty())day.pop_back();
}
deque <int> ind;
for(auto x : v){
day.pb(x.ff);
ind.pb(x.ss);
}
vector <vector <int> > ans(n+1);
cout<<r<<"\n";
for(int i=1;i<=n;i++){
int cnt=r;
while(day.size()!=0 && day.front()>=i-d && day.front()<=i && cnt>0){
day.pop_front();
ans[i].pb(ind.front());
ind.pop_front();
cnt--;
}
ans[i].pb(0);
}
for(int i=1;i<=n;i++){
for(auto x : ans[i])cout<<x<<" ";
cout<<"\n";
}
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
5836 KB |
Expected EOLN |
2 |
Incorrect |
31 ms |
5824 KB |
Expected EOLN |
3 |
Incorrect |
31 ms |
5844 KB |
Expected EOLN |
4 |
Incorrect |
32 ms |
5836 KB |
Expected EOLN |
5 |
Incorrect |
31 ms |
5836 KB |
Expected EOLN |
6 |
Incorrect |
31 ms |
5824 KB |
Expected EOLN |
7 |
Incorrect |
32 ms |
5680 KB |
Expected EOLN |
8 |
Incorrect |
32 ms |
5828 KB |
Expected EOLN |
9 |
Incorrect |
49 ms |
9680 KB |
Expected EOLN |
10 |
Incorrect |
54 ms |
9740 KB |
Expected EOLN |
11 |
Incorrect |
37 ms |
4284 KB |
Expected EOLN |
12 |
Incorrect |
74 ms |
8116 KB |
Expected EOLN |
13 |
Incorrect |
110 ms |
12988 KB |
Expected EOLN |
14 |
Incorrect |
178 ms |
18076 KB |
Expected EOLN |
15 |
Incorrect |
208 ms |
19888 KB |
Expected EOLN |
16 |
Incorrect |
251 ms |
24100 KB |
Expected EOLN |
17 |
Incorrect |
295 ms |
29056 KB |
Expected EOLN |
18 |
Runtime error |
311 ms |
33448 KB |
Memory limit exceeded |
19 |
Runtime error |
419 ms |
40164 KB |
Memory limit exceeded |
20 |
Incorrect |
296 ms |
29092 KB |
Expected EOLN |