Pagini recente » Cod sursa (job #1636373) | Cod sursa (job #2729235) | Cod sursa (job #2318334) | Cod sursa (job #2719916) | Cod sursa (job #1101761)
program el_maj;
const nmax=1000005;
var a:array[1..nmax] of longint;
n,i,k,cand,nr,x:longint;
begin
assign(input,'elmaj.in');
reset(input);
assign(output,'elmaj.out');
rewrite(output);
readln(n);
for i:=1 to n do read(a[i]);
cand:=-1;
k:=0;
for i:=1 to n do
begin
if k=0 then begin cand:=a[i]; k:=1; end
else
if a[i]=cand then k:=k+1
else k:=k-1;
end;
nr:=0;
for i:=1 to n do if a[i]=cand then nr:=nr+1;
if nr>=n div 2+1 then write(cand,' ',nr)
else write(-1);
CLOSE(OUTPUT);
END.