Pagini recente » Borderou de evaluare (job #383721) | Borderou de evaluare (job #2334306) | Cod sursa (job #505113) | Cod sursa (job #394160) | Cod sursa (job #687186)
Cod sursa(job #687186)
program elmaj;
const fi='elmaj.in';
fo='elmaj.out';
var f,g:text;
bufin,bufout:array[1..65000] of char;
v:array[1..1000000] of longint;
n,i,cand,k,nr:longint;
begin
assign(f,fi);
reset(f);
assign(g,fo);
rewrite(g);
settextbuf(f,bufin);
settextbuf(f,bufout);
read(f,n);
for i:=1 to n do
begin
read(f,v[i]);
end;
cand:=-1;
k:=0;
for i:=1 to n do
if k=0 then
begin
cand:=v[i];
k:=1;
end
else
if v[i]=cand then
inc(k)
else
dec(k);
if cand<>0 then
begin
nr:=0;
for i:=1 to n do
if v[i]=cand then
inc(nr);
if (nr>n/2) then
writeln(g,cand,' ',nr)
else
writeln(g,-1);
write(-1);
end;
close(f);
close(g);
end.