#include <bits/stdc++.h>
using
namespace
std;
void
print(
int
rStation[],
int
n)
{
for
(
int
i = 1; i <= n; i++)
cout << rStation[i] <<
" "
;
cout << endl;
}
void
radiated_Station(
int
station[],
int
n)
{
int
rStation[n + 1];
int
left_Rad[n + 2], right_Rad[n + 2];
int
lCount[n + 2], rCount[n + 2];
memset
(left_Rad, 0,
sizeof
(left_Rad));
memset
(right_Rad, 0,
sizeof
(right_Rad));
memset
(lCount, 0,
sizeof
(lCount));
memset
(rCount, 0,
sizeof
(rCount));
for
(
int
i = 1; i < n + 1; i++) {
int
Rad = station[i];
int
li = max(1, i - Rad + 1), ri = min(n, Rad - 1 + i);
int
at1 = max(0, Rad - i + 1);
left_Rad[1] += at1;
left_Rad[i + 1] -= Rad;
int
atn = max(0, Rad - n + i);
right_Rad[n] += atn;
right_Rad[i - 1] -= Rad;
lCount[li]++;
rCount[ri]++;
lCount[i + 1]--;
rCount[i - 1]--;
}
for
(
int
i = 1; i <= n; i++) {
lCount[i] += lCount[i - 1];
if
(i > 1)
left_Rad[i] += left_Rad[i - 1] + lCount[i];
}
for
(
int
i = n; i >= 1; i--) {
rCount[i] += rCount[i + 1];
if
(i < n)
right_Rad[i] += right_Rad[i + 1] + rCount[i];
}
for
(
int
i = 1; i <= n; i++) {
rStation[i] = left_Rad[i] + right_Rad[i] - station[i];
}
print(rStation, n);
}
int
main()
{
int
station[] = { 0, 7, 9, 12, 2, 5 };
int
n = (
sizeof
(station) /
sizeof
(station[0])) - 1;
radiated_Station(station, n);
return
0;
}