var
a:array[1..100000] of longint;
n,i,x:longint;
sum:int64;
begin
readln(n);
for i:=1 to n do read(a[i]);
for i:=2 to n-1 do
begin
if (a[i]>a[i+1])and(a[i]>a[i-1])then
begin
if a[i-1]>a[i+1] then x:=a[i-1] else x:=a[i+1];
inc(sum,a[i]-x);
a[i]:=x;
end
else
begin
if (a[i]
KMP
最新推荐文章于 2023-01-23 18:57:44 发布