(亏了这是1700分的贪心......完全是模拟嘛......)
(贪心思路还是很显然的,维护一个当前要放的板子数)
(每次选取能到的最远地方放板子,如果选那个地方导致板子放不下)
(那就选一个尽量远的地方)
(正确性是显然的,因为我们可以跳[1,d]间任意数目步子)
#include <bits/stdc++.h>
using namespace std;
int n,m,d,sumn;
int a[1009],ans[1009];
void work(int l,int r,int num){
for(int i=l;i<=r;i++) ans[i]=num;
}
void over(){
cout<<"NO",exit(0);
}
int main()
{
cin>>n>>m>>d;
for(int i=1;i<=m;i++) cin>>a[i],sumn+=a[i];
int last=0;
for(int i=1;i<=m;i++)
{
int far=last+d;//最远可以放在这里
int ss=n-far+1;//还可以放这么多块板子
if(ss>=sumn) work(far,far+a[i]-1,i);
else
{
far=n-sumn+1;
if(far<=last) over();
work(far,far+a[i]-1,i);
}
last=far+a[i]-1;
sumn-=a[i];
}
if(n+1-last>d) over();
cout<<"YES"<<endl;
for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
}