a = int(input())
A = list(map(int, input().split()))
m = [[0, 0, 0]]
for i in range(a):
if A[i] != 5:
n = []
n.append(i + 1)
x = 0
while A[i] != 5:
x += 5 - A[i]
i += 1
if i == a:
break
n.append(i)
n.append(x)
if n[2] > m[0][2]:
m[0] = n
elif n[2] == m[0][2]:
m.append(n)
for row in m:
print(*row)
Объяснение:
const
nmax = 100;
n = 10;
var
a: array[1..nmax, 1..nmax]of integer;
i, j: byte;
begin
for i := 1 to N do
for j := 1 to N do
A[i, j] := Random(-10, 10);
write(A[i, j]:5);
end;
writeln;
end.
Тестовое решение
-2 7 -10 -3 -4 6 -6 8 0 8
10 -8 10 2 -2 7 -8 -7 5 9
-4 4 3 -8 -4 -4 -8 7 1 10
-8 3 -5 0 3 -9 -7 1 -7 -4
2 2 8 -2 1 10 -7 7 6 7
-6 -2 9 8 -4 4 -6 8 -9 10
4 -3 -4 1 5 -3 7 0 10 -4
3 2 10 -1 -3 4 7 -5 2 -3
-8 -4 -9 5 6 4 4 -2 -7 9
8 -4 0 -7 3 -6 -5 -3 3 -6
a = int(input())
A = list(map(int, input().split()))
m = [[0, 0, 0]]
for i in range(a):
if A[i] != 5:
n = []
n.append(i + 1)
x = 0
while A[i] != 5:
x += 5 - A[i]
i += 1
if i == a:
break
n.append(i)
n.append(x)
if n[2] > m[0][2]:
m = [[0, 0, 0]]
m[0] = n
elif n[2] == m[0][2]:
m.append(n)
for row in m:
print(*row)
Объяснение:
a = int(input())
A = list(map(int, input().split()))
m = [[0, 0, 0]]
for i in range(a):
if A[i] != 5:
n = []
n.append(i + 1)
x = 0
while A[i] != 5:
x += 5 - A[i]
i += 1
if i == a:
break
n.append(i)
n.append(x)
if n[2] > m[0][2]:
m = [[0, 0, 0]]
m[0] = n
elif n[2] == m[0][2]:
m.append(n)
for row in m:
print(*row)
const
nmax = 100;
n = 10;
var
a: array[1..nmax, 1..nmax]of integer;
var
i, j: byte;
begin
for i := 1 to N do
begin
for j := 1 to N do
begin
A[i, j] := Random(-10, 10);
write(A[i, j]:5);
end;
writeln;
end;
end.
Тестовое решение
-2 7 -10 -3 -4 6 -6 8 0 8
10 -8 10 2 -2 7 -8 -7 5 9
-4 4 3 -8 -4 -4 -8 7 1 10
-8 3 -5 0 3 -9 -7 1 -7 -4
2 2 8 -2 1 10 -7 7 6 7
-6 -2 9 8 -4 4 -6 8 -9 10
4 -3 -4 1 5 -3 7 0 10 -4
3 2 10 -1 -3 4 7 -5 2 -3
-8 -4 -9 5 6 4 4 -2 -7 9
8 -4 0 -7 3 -6 -5 -3 3 -6