Pagini recente » Cod sursa (job #2003783) | Istoria paginii runda/simulareoni2007/clasament | Cod sursa (job #663844) | Cod sursa (job #659949) | Cod sursa (job #1108445)
var i,n,candidat,k:longint;
a:array[1..1000001] of longint;
buf1,buf2:array[1..1 shl 16] of char;
begin
assign(input,'elmaj.in');
assign(output,'elmaj.out');
reset(input);
rewrite(output);
settextbuf(input,buf1);
settextbuf(output,buf2);
readln(n);
for i:=1 to n do
read(a[i]);
candidat:=-1; k:=0;
for i:=1 to n do
if k=0 then begin
candidat:=a[i];
k:=1;
end
else if candidat=a[i] then inc(k)
else dec(k);
k:=0;
for i:=1 to n do
if candidat=a[i] then inc(k);
if k>=n div 2 + 1 then write(candidat,' ',k)
else write('-1');
close(input);
close(output);
{Totusi este trist in lume}
end.