Pagini recente » Cod sursa (job #1943412) | Cod sursa (job #1793171) | Cod sursa (job #524345) | Cod sursa (job #2359088) | Cod sursa (job #2548182)
var t:array[1..1000005] of longint;
n,i,x,xp,mx:longint;
begin
assign(input,'elmaj.in'); reset(input);
assign(output,'elmaj.out'); rewrite(output);
readln(n);
for i:=1 to n do read(t[i]);
mx:=t[1]; x:=1;
for i:=2 to n do
begin
if x=0 then
begin
mx:=t[i];
x:=1
end else
if t[i]=mx then inc(x) else dec(x)
end;
if x>=0 then
begin
for i:=1 to n do
if t[i]=mx then inc(xp);
if xp>=n div 2+1 then writeln(mx,' ',xp) else writeln('-1')
end;
close(input);
close(output)
end.