题解:AT_abc388_d [ABC388D] Coming of Age Celebration
思路:
模拟。
定义一个变量
每一个成年的人在自己还要珠子的时候必须要给刚刚成年的人一个珠子,所以第
更新完第
代码:
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define itn int
#define ull unsigned long long
LL T=1;
LL n;
LL a[int(5*1e5+10)];
LL R[int(5*1e5+10)];
int main(){
// cin>>T;
while(T--){
cin>>n;
int give=0;
for(int i=1;i<=n;i++){
cin>>a[i];
// cout<<give<<"\n";
if(a[i]-(n-i)+give<0){
R[a[i]+give+i]++;
a[i]=0;
}
else{
a[i]=a[i]-(n-i)+give;
}
give++;
give-=R[i];
cout<<a[i]<<" ";
}
}
return 0;
}