Pagini recente » Cod sursa (job #1692137) | Cod sursa (job #2830248) | Cod sursa (job #1160753) | Cod sursa (job #2461624) | Cod sursa (job #226762)
Cod sursa(job #226762)
var f,g:text;
v,c:array[0..100010]of longint;
n,a,b,s,t,i:longint;
begin
assign(f,'oo.in');
assign(g,'oo.out');
reset(f);
rewrite(g);
read(f,n);
read(f,a);
for i:=2 to n-1 do
begin
read(f,b);
if (i<5)then s:=0 else s:=v[i-4];
v[i-1]:=a+b+s;
if (v[i-1]<v[i-2])then
v[i-1]:=v[i-2];
if (i>2)then
begin
if (i<5)then s:=0 else s:=c[i-4];
c[i-1]:=a+b+s;
if (c[i-2]>c[i-1])then c[i-1]:=c[i-2];
end;
a:=b;
end;
read(f,b);
if (n<5)then s:=0 else s:=c[n-4];
t:=s+a+b;
if (t<v[n-2])then t:=v[n-2];
if (n<5)then s:=0 else s:=v[n-4];
if (s>t)then write(g,s)else write(g,t);
close(f);
close(g);
end.