Pagini recente » Cod sursa (job #2544895) | Cod sursa (job #317007) | Cod sursa (job #2545085) | Cod sursa (job #1615356) | Cod sursa (job #820552)
Cod sursa(job #820552)
var fi,fo:text;
n,i:longint;
a:array[1..1000001] of longint;
procedure citire;
begin
readln(fi,n);
for i:=1 to n do
read(fi,a[i]);
end;
procedure calculare;
var nr,cand,k:longint;
begin
cand:=-1; k:=0;
for i:=1 to n do
if (k=0) then begin cand:=a[i]; k:=1; end else
if (a[i]=cand) then inc(k) else dec(k);
if (cand<0) then begin writeln(fo,-1); halt; end;
nr:=0;
for i:=1 to n do
if (a[i]=cand) then inc(nr);
if (nr>n div 2) then writeln(fo,cand,' ', nr);
end;
BEGIN
assign(fi,'elmaj.in'); reset(fi);
assign(fo,'elmaj.out'); rewrite(fo);
citire;
calculare;
close(fi); close(fo);
END.