Python 3.6
n = int(input())
a = [int(i) for i in input().split()]
up, now, max_, min_ = False, 0, 0, 0
if n == 1:
print('0 0')
else:
for i in range(1, n):
if a[i - 1] < a[i]:
if not up:
up = True
now = 0
now += a[i] - a[i-1]
if now > max_:
max_ = now
if a[i-1] > a[i]:
if up:
up = False
now += a[i-1] - a[i]
if now > min_:
min_ = now
print(max_, min_)
PascalABC.NET 3.5.1
Program c_contest;
var Data: array of longword;
i, n, count, max, min, now: longword;
up: boolean;
F: textfile;
begin
Assign(F, 'input.txt');
Reset(F);
readln(F, n);
SetLength(Data, n);
for i := 0 to n-1 do
read(F, Data[i]);
end;
Close(F);
if n = 1 then write('0 0')
else
for i := 1 to n-1 do
if Data[i-1] < Data[i] Then
if not up Then
up := True;
now := 0;
now := now + (Data[i] - Data[i-1]);
if now > max Then max := now;
if Data[i-1] > Data[i] Then
if up Then
up := False;
now := now + (Data[i-1] - Data[i]);
if now > min Then min := now;
write(max, ' ',min);
end.
Объяснение:
По коду видно
ab = abs(a[1] - a[2])
if ab > 180:
ab = 360 - ab
if ab % a[4] == 0:
x = ab // a[4]
x = ab // a[4] + 1
if a[0] % a[3] == 0:
x += a[0] // a[3]
x += a[0] // a[3] + 1
print(x)
program who;
var a, b, ab, t: integer;
d, s, x: LongInt;
read(d, a, b, s, t);
ab := abs(a - b);
if ab > 180 then
ab := 360 - ab;
if ab mod t = 0 then
x := ab div t
x := ab div t + 1;
if d mod s = 0 then
x := x + d div s
x := x + d div s + 1;
write(x);
Думаю по коду поймешь
Python 3.6
n = int(input())
a = [int(i) for i in input().split()]
up, now, max_, min_ = False, 0, 0, 0
if n == 1:
print('0 0')
else:
for i in range(1, n):
if a[i - 1] < a[i]:
if not up:
up = True
now = 0
now += a[i] - a[i-1]
if now > max_:
max_ = now
if a[i-1] > a[i]:
if up:
up = False
now = 0
now += a[i-1] - a[i]
if now > min_:
min_ = now
print(max_, min_)
PascalABC.NET 3.5.1
Program c_contest;
var Data: array of longword;
i, n, count, max, min, now: longword;
up: boolean;
F: textfile;
begin
Assign(F, 'input.txt');
Reset(F);
readln(F, n);
SetLength(Data, n);
for i := 0 to n-1 do
begin
read(F, Data[i]);
end;
Close(F);
if n = 1 then write('0 0')
else
begin
for i := 1 to n-1 do
begin
if Data[i-1] < Data[i] Then
begin
if not up Then
begin
up := True;
now := 0;
end;
now := now + (Data[i] - Data[i-1]);
if now > max Then max := now;
end;
if Data[i-1] > Data[i] Then
begin
if up Then
begin
up := False;
now := 0;
end;
now := now + (Data[i-1] - Data[i]);
if now > min Then min := now;
end;
end;
write(max, ' ',min);
end;
end.
Объяснение:
По коду видно
Python 3.6
a = [int(i) for i in input().split()]
ab = abs(a[1] - a[2])
if ab > 180:
ab = 360 - ab
if ab % a[4] == 0:
x = ab // a[4]
else:
x = ab // a[4] + 1
if a[0] % a[3] == 0:
x += a[0] // a[3]
else:
x += a[0] // a[3] + 1
print(x)
PascalABC.NET 3.5.1
program who;
var a, b, ab, t: integer;
d, s, x: LongInt;
begin
read(d, a, b, s, t);
ab := abs(a - b);
if ab > 180 then
ab := 360 - ab;
if ab mod t = 0 then
x := ab div t
else
x := ab div t + 1;
if d mod s = 0 then
x := x + d div s
else
x := x + d div s + 1;
write(x);
end.
Объяснение:
Думаю по коду поймешь