N=int(input())
a=[]
sum = 0
f = 0
c = 0
for i in range(N):
l = int(input())
sum = sum + l
a.append(l)
if N == 1:
print(1)
else:
ans = []
for i in range(N-1, 0, -1):
if a[i] > a[i-1]:
if sum > a[-1] or (sum > a[i+1] and f == 1):
for k in range(c+1):
ans.append(1)
f = 1
ans.append(0)
elif a[i] == a[i-1]:
c += 1
sum=sum-a[i]
ans = ans[::-1]
print(0)
for i in range(c):
for i in ans:
print(i)
Объяснение:
с тебя 500 рублей у меня сегодня др
Program fantscrin;
const n = 10;
Var a: array [1..n] of integer;
b: array [1..n] of integer;
i,j:integer;
Begin
j:=0;
for i:=1 to n do
a[i]:=random(20);
write(a[i], ' ');
if (i mod 2 <> 0) then
begin
j:=j+1;
b[j]:=a[i];
end;
writeln('');
a[i]:=0;
for i:=1 to j do
a[i]:=b[i];
writeln(j);
End.
N=int(input())
a=[]
sum = 0
f = 0
c = 0
for i in range(N):
l = int(input())
sum = sum + l
a.append(l)
if N == 1:
print(1)
else:
ans = []
for i in range(N-1, 0, -1):
if a[i] > a[i-1]:
if sum > a[-1] or (sum > a[i+1] and f == 1):
for k in range(c+1):
ans.append(1)
c = 0
f = 1
else:
ans.append(0)
f = 0
elif a[i] == a[i-1]:
c += 1
else:
ans.append(0)
f = 0
sum=sum-a[i]
ans = ans[::-1]
print(0)
for i in range(c):
print(0)
for i in ans:
print(i)
Объяснение:
с тебя 500 рублей у меня сегодня др
Program fantscrin;
const n = 10;
Var a: array [1..n] of integer;
b: array [1..n] of integer;
i,j:integer;
Begin
j:=0;
for i:=1 to n do
a[i]:=random(20);
for i:=1 to n do
write(a[i], ' ');
for i:=1 to n do
if (i mod 2 <> 0) then
begin
j:=j+1;
b[j]:=a[i];
end;
writeln('');
for i:=1 to n do
a[i]:=0;
for i:=1 to j do
a[i]:=b[i];
for i:=1 to j do
write(a[i], ' ');
writeln('');
writeln(j);
End.