Pagini recente » Cod sursa (job #1667794) | Cod sursa (job #2872652) | Cod sursa (job #1380126) | Cod sursa (job #3160512) | Cod sursa (job #964379)
Cod sursa(job #964379)
program elmaj;
var bufin:array[1..100000]of char;
a:array [1..1000000] of longint;
n,i,ans,k:longint;
begin
assign(input,'elmaj.in');
reset(input);
settextbuf(input,bufin);
assign(output,'elmaj.out');
rewrite(output);
readln(n);
for i:=1 to n do
begin
read(a[i]);
if ans=0 then
begin
ans:=a[i];
k:=1;
end else
if ans<>a[i] then
begin
dec(k);
if k=0 then ans:=0;
end
else inc(k);
end;
k:=0;
for i:=1 to n do
if a[i]=ans then inc(k);
if k>=n div 2 +1 then writeln(ans,' ',k) else writeln(-1);
close(output);
end.