Pagini recente » Cod sursa (job #355897) | Cod sursa (job #131752) | Cod sursa (job #238084) | Cod sursa (job #1235943) | Cod sursa (job #291138)
Cod sursa(job #291138)
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-1 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.