Pagini recente » Cod sursa (job #3282369) | Cod sursa (job #1519156) | Cod sursa (job #2582337) | Cod sursa (job #1044114) | Cod sursa (job #673046)
Cod sursa(job #673046)
program eeel;
var n,i,poz,max,max2:longint;
f,g:text;
v,fr:array[1..1000000] of longint;
bufin:array[1..1000000] of longint;
begin
assign(f,'elmaj.in'); reset(f);
assign(g,'elmaj.out'); rewrite(g);
max:=0;
settextbuf(f,bufin);
readln(f,n);
for i:=1 to n do
begin
read(f,v[i]);
fr[v[i]]:=fr[v[i]]+1;
if v[i]>max then
max:=v[i];
end;
for i:=1 to max do
if fr[v[i]]>max2 then
begin
max2:=fr[v[i]];
poz:=v[i];
end;
if max2<n div 2+1 then
write(g,-1)
else
write(g,poz,' ',max2);
close(f);
close(g);
end.