Pagini recente » Cod sursa (job #1888751) | Cod sursa (job #406912) | Cod sursa (job #1341640) | Cod sursa (job #16049) | Cod sursa (job #291143)
Cod sursa(job #291143)
program scmax;
type vec=array [1..1000] of longint;
var i,n,m,j:longint;
f,t:text;
a,b:vec;
dif:boolean;
begin
assign(f,'scmax.in');
reset(f);
assign(t,'scmax.out');
rewrite(t);
read(f,n);
for i:=1 to n do
read(f,a[i]);
m:=0;
for i:=1 to n do
begin
if a[i]<a[i+1]
then begin
dif:=true;
for j:=1 to m do
if a[i]=b[j]
then dif:=false;
if dif then
begin
m:=m+1;
b[m]:=a[i];
end;
end;
end;
if a[n]>a[n-1]
then
begin
m:=m+1;
b[m]:=a[n];
end;
writeln(t,m);
for i:=1 to m do
write(t,b[i],' ');
close(f);
close(t);
end.