N = int(input())
if N == 1:
exit(0)
bacteria = [0] * N
for i in range(0, N):
bacteria[i] = int(input())
prefix_sum = [bacteria[0]] * N
for i in range(1, N):
prefix_sum[i] = prefix_sum[i - 1] + bacteria[i]
ans = [0] * N
if bacteria[N-1] > bacteria[0]:
ans[N - 1] = 1
for i in reversed(range(2, N)):
if ans[i] == 1:
prev = i - 1
if prefix_sum[prev] > bacteria[i] and bacteria[0] < bacteria[prev]:
ans[prev] = 1
for i in range(N):
print(ans[i])
Объяснение:
h++
g++
N = int(input())
if N == 1:
exit(0)
bacteria = [0] * N
for i in range(0, N):
bacteria[i] = int(input())
prefix_sum = [bacteria[0]] * N
for i in range(1, N):
prefix_sum[i] = prefix_sum[i - 1] + bacteria[i]
ans = [0] * N
if bacteria[N-1] > bacteria[0]:
ans[N - 1] = 1
for i in reversed(range(2, N)):
if ans[i] == 1:
prev = i - 1
if prefix_sum[prev] > bacteria[i] and bacteria[0] < bacteria[prev]:
ans[prev] = 1
for i in range(N):
print(ans[i])
Объяснение:
h++
N = int(input())
if N == 1:
exit(0)
bacteria = [0] * N
for i in range(0, N):
bacteria[i] = int(input())
prefix_sum = [bacteria[0]] * N
for i in range(1, N):
prefix_sum[i] = prefix_sum[i - 1] + bacteria[i]
ans = [0] * N
if bacteria[N-1] > bacteria[0]:
ans[N - 1] = 1
for i in reversed(range(2, N)):
if ans[i] == 1:
prev = i - 1
if prefix_sum[prev] > bacteria[i] and bacteria[0] < bacteria[prev]:
ans[prev] = 1
for i in range(N):
print(ans[i])
Объяснение:
g++