Pagini recente » Cod sursa (job #967658) | Cod sursa (job #504233) | Cod sursa (job #1377781) | Cod sursa (job #536804) | Cod sursa (job #1409978)
program elmaj;
var nr,x,n,m,c,i,j:longint;
bufin,bufout:array[1..1 shl 16] of byte;
v:array[1..1000001] of longint;
begin
assign(input,'elmaj.in'); reset(input);
assign(output,'elmaj.out'); rewrite(output);
settextbuf(input,bufin);
settextbuf(output,bufout);
readln(n);
read(v[1]);
m:=1; c:=1;
for i:=2 to n do
begin
read(v[i]);
if v[i]=m then inc(c)
else
begin
dec(c);
if c=0 then
begin
m:=v[i];
c:=1;
end;
end;
end;
close(input);
reset(input);
readln(n);
nr:=0;
for i:=1 to n do
if v[i]=m then inc(nr);
if nr>=(n div 2) +1 then writeln(m,' ',nr)
else writeln('-1');
close(output);
end.