Mai intai trebuie sa te autentifici.

Cod sursa(job #1409962)

Utilizator casianos1996Marc Casian Nicolae casianos1996 Data 30 martie 2015 19:50:34
Problema Elementul majoritar Scor 80
Compilator fpc Status done
Runda Arhiva educationala Marime 0.7 kb
program elmaj;
var     nr,x,n,m,c,i,j:longint;
        bufin,bufout:array[1..1 shl 17] of byte;
begin
  assign(input,'elmaj.in'); reset(input);
  assign(output,'elmaj.out'); rewrite(output);
  settextbuf(input,bufin);
  settextbuf(output,bufout);
  readln(n);
  m:=-1; c:=1;
  for i:=1 to n do
    begin
      read(x);
      if x=m then inc(c)
      else
        begin
          dec(c);
          if c=0 then
            begin
              m:=x;
              c:=1;
            end;
        end;
    end;
  close(input);
  reset(input);
  readln(n);
  nr:=0;
  for i:=1 to n do
    begin
      read(x);
      if x=m then inc(nr);
    end;
  writeln(m,' ',nr);
  close(output);
end.