Cod sursa(job #290730)

Utilizator Cristian_BBerceanu Cristian Cristian_B Data 28 martie 2009 16:37:35
Problema Subsir crescator maximal Scor 10
Compilator fpc Status done
Runda Arhiva educationala Marime 0.67 kb
var l,i,j,n:longint;
    ct,ms,max:longint;
    rst,st,v:array[1..100000] of longint;
    f,g:text;
procedure load;
begin
assign(f,'scmax.in');
reset(f);
readln(f,n);
for i:=1 to n do
read(f,v[i]);
close(f);
assign(g,'scmax.out');
rewrite(g);

end;
BEGIN
load;
ms:=0;
for i:=1 to n do
begin
 j:=i;max:=v[i];l:=0;
 while max<=v[j] do
  begin
    max:=v[j];
    l:=l+1;
    if v[j]<>st[l-1] then
    st[l]:=v[j];
    j:=j+1;
    if ms<l then
    begin
     ms:=l;
     rst:=st;
    end;
  end;
end;
ct:=0;
for i:=1 to ms do
if rst[i]<>0 then
ct:=ct+1;
writeln(g,ct);
for i:=1 to ms do
if rst[i]<>0 then
write(g,rst[i],' ');
closE(g);
END.