Pagini recente » Cod sursa (job #3159198) | Borderou de evaluare (job #366975) | Cod sursa (job #344472) | Cod sursa (job #1660316) | Cod sursa (job #335594)
Cod sursa(job #335594)
Program scmax;
type lista = ^celula;
celula = record
num:longint;
next:lista;
end;
var f,g:text; a:array[1..100000]of longint;
b:array[1..100000]of longint;
c:array[1..100000,1..2]of lista;
n,max:longint;
procedure initiere;
var x:longint;
begin
assign (f,'scmax.in'); reset (f);
assign (g,'scmax.out'); rewrite (g);
readln (f,n);
for x:=1 to n do begin
read (f,a[x]);
b[x]:=1;
new (c[x,1]);
c[x,1]^.num:=a[x];
c[x,2]:=c[x,1];
end;
end;
procedure incheiere;
begin
close (f); close (g);
end;
function maxim (x,y:longint):longint;
begin
if b[x]+1>b[y] then begin
b[y]:=b[x]+1;
end;
end;
procedure calcul;
var x,y,z:longint;
begin
max:=1;
z:=1;
for x:=1 to n-1 do
for y:=x+1 to n do
if a[x]<a[y] then begin
maxim (x,y);
if b[y]>max then begin
max:=b[y];
z:=y;
end;
end;
writeln (g,b[z]);
writeln (g,'Casuta: ',z);
end;
begin
initiere;
calcul;
incheiere;
end.