题解:CF1392F Omkar and Landslide
手玩一下,我们发现最终的情况一定是一个
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 1e6+114;
int a[maxn],n;
int d,pos,h;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
d=h=a[1];
for(int i=2;i<=n;i++){
h++;
int c=a[i]-h;
int t=i-1-pos;
if(c==0) continue;
if(c<=t){
if(pos==0) d++;
pos+=c;
}else{
if(pos==0) d++;
c-=(t+1);
pos=0;
h++;
int f=c/i;
c%=i;
d+=f;
h+=f;
if(c>0){
d++;
pos=c;
}
}
/*
for(int j=1;j<=c;j++){
if(pos==0){
pos=1;
d++;
}else if(pos+1<i){
pos++;
}else{
pos=0;
h++;
}
}*/
//cout<<d<<' '<<h<<' '<<pos<<'\n';
}
cout<<d<<" ";
for(int i=2;i<=n;i++){
cout<<d+i-1-(pos==0?0:1)*(pos+1<=i?1:0)<<' ';
}
return 0;
}