#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,d;
cin>>n>>d>>m;
vector<pair<int,int>>xd(m);
for(int i=0;i<m;i++){
int x;
cin>>x;
xd[i]={x,i+1};
}
sort(xd.begin(),xd.end());
int lewo=1,prawo=m+1;
while(lewo<=prawo){
int mid=lewo+(prawo-lewo)/2;
int akt=0;
int ile=0;
for(int i=1;i<=n;i++){
if(xd[ile].first+d<i)
break;
while(akt<mid && xd[ile].first<=i)
{
akt++;
ile++;
}
}
if(ile<=m)
lewo=mid+1;
else
prawo=mid-1;
}
cout<<lewo<<'\n';
int ile=0;
for(int i=0;i<n;i++){
for(int j=0;j<lewo;j++){
if(ile<m)
cout<<xd[ile].second<<' ';
ile++;
}
cout<<0<<'\n';
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |