Pagini recente » Cod sursa (job #1669169) | Cod sursa (job #3235825) | Cod sursa (job #2446187) | Cod sursa (job #2592146) | Cod sursa (job #875647)
Cod sursa(job #875647)
var n,cont,curent,i,x:longint;
a:array[1..1000001]of longint;
bufin:array[1..65000]of byte;
begin
assign(input,'elmaj.in'); reset(input);
assign(output,'elmaj.out'); rewrite(output);
settextbuf(input,bufin);
readln(n);
read(curent); cont := 1; a[1] := curent;
for i := 2 to n do
begin
read(a[i]);
if (cont = 0)and(curent<>a[i]) then
begin
curent := a[i];
inc(cont);
end
else
begin
if a[i] = curent then
inc(cont)
else
dec(cont);
end;
end;
if cont <= 0 then
write('-1')
else
begin
write(curent,' ');
cont := 0;
for i := 1 to n do
if a[i] = curent then inc(cont);
write(cont);
end;
close(input);
close(output);
end.