var a: array [1..5] of integer;
i, j , count: integer;
repeated : boolean;
begin
for i := 1 to 5 do
begin
write('Введите ', i, '-e число: ');
readln(a[i]);
end;
for i := 1 to 5 do
begin
repeated := false;
for j := 1 to i - 1 do
if (a[i] = a[j]) then
repeated := true;
if repeated then continue;
count := 1;
for j:= i+1 to 5 do
if (a[i]=a[j]) then
inc(count);
writeln('Число ', a[i], ' встречается ', count,' раз');
end;
end.
def process(array):
result = []
for i in range(1, len(array)-1):
if (array[i] < 0 and array[i-1] < 0) or \
(array[i] < 0 and array[i+1] < 0) or \
(array[i] > 0 and array[i-1] > 0) or \
(array[i] > 0 and array[i+1] > 0):
return 'YES'
return 'NO'
def main():
N = int(input())
assert N>=1 and N<= 10000
input_array = [int(i) for i in input().split()]
assert len(input_array) == N
print(process(input_array))
if __name__ == '__main__':
main()
Объяснение:
Протестировано на стандартном вводе/выводе + один доп тест
Доп тест:
Ввод:
5
1 2 -2 3 -4
Вывод:
YES
P.S Сайт ломает Python-код. Ниже приложен скриншот исходного кода
Объяснение:
Вид