Cod sursa(job #2524171)

Utilizator bitonekoTraian Omin bitoneko Data 15 ianuarie 2020 10:17:42
Problema A+B Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <fstream>

using namespace std;
ifstream cin("ou.in");
ofstream cout("ou.out");
long long int mark[100001],v[100000];
int main()
{
  #define int long long
  int n,width,many;
  cin >> n;
  for(int i=0; i<n; i++)
    cin >> v[i];
  for(int i=1; i<n-1; i++) {
    if(v[i]<2)
      continue;
    width=min(i,n-i-1);
    if(v[i]<width*2) {
      width=v[i]/2;
      many=1;
    }
    else
      many=v[i]/(width*2);
    v[i]-=width*2*many;
    mark[i-width]+=many;
    mark[i]-=many;
    mark[i+1]+=many;
    mark[i+width+1]-=many;
  }
  int accum=0;
  for(int i=0; i<n; i++) {
    accum+=mark[i];
    cout << accum+v[i] << ' ';
  }
  return 0;
}
/**

10
22 6 8 5 2 1 1 14 10 13

*/