Untitled

 avatar
unknown
c_cpp
21 days ago
424 B
2
Indexable
#include <bits/stdc++.h>
using namespace std;

const int N = 5e+5;


int main() 
{
    int n;
    cin >> n;
    std::vector<int> v(n), d(n+5);
    for(auto& x : v) cin >> x;
    for(int i = 0; i < n; ++i){
      if(i) d[i] += d[i-1];
      v[i] += d[i];
      int c = min(v[i], n-1-i);
      if(c) d[i+1] += 1, d[i+c+1] -= 1;
      v[i] -= c;
    }
    for(auto& x : v) cout << x << " ";
    return 0;
}
Editor is loading...
Leave a Comment