Pagini recente » Cod sursa (job #333538) | Cod sursa (job #923426) | Cod sursa (job #324855) | Cod sursa (job #526123) | Cod sursa (job #65361)
Cod sursa(job #65361)
var a,b:array[1..5000] of longint;
min,n,i,j,k,l,max,poz:longint;
begin
assign(input,'subsir2.in');
assign(output,'subsir2.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do read(a[i]);
b[n]:=1;
for i:=n-1 downto 1 do
begin
max:=0;
for j:=i+1 to n do
if (a[i]<a[j])and(max<b[j]) then max:=b[j];
b[i]:=max+1;
end;
max:=0;
for i:=1 to n do
if b[i]>max then max:=b[i];
writeln(max);
poz:=1;
repeat
min:=maxlongint;
for i:=poz to n do
if (b[i]=max)and(a[i]<min) then begin
min:=a[i];
poz:=i;
end;
write(poz,' ');
dec(max);
until max=0;
close(input);
close(output);
end.