ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

Whi TL HELP ME PLEASE. THENCKS
Posted by I am david. Tabo. 26 Oct 2002 19:25
var ni,k,i,j,max,m,n:longint;
    a,b:array [1..25001] of integer;
    q:array [1..1001] of byte;
    s:boolean;

begin
  readln (k);
  for j:=1 to k do
    begin
      readln (n);
      for i:=1 to n do
        begin
          if i<>n then
            read (a[i])
          else
            readln (a[i]);
          if a[i]<>0 then
            inc (b[a[i]]);
        end;
      max:=b[1];
      for i:=2 to n do
        if max<b[i] then
          max:=b[i];
      for i:=1 to n do
        if (b[i]=max) then
          inc (m);
      ni:=0;
      if m=1 then
        begin
          q[j]:=1;
          s:=true;
        end
      else
        for i:=1 to n do
          if (a[i]=0)and(b[i]<>0) then
            begin
              q[j]:=1;
              if ni=1 then
                begin
                  q[j]:=0;
                  break;
                end;
              inc (ni);
              s:=true;
            end;
      if not s then
        q[j]:=0;
      s:=false;
      fillchar(a,sizeof(a),0);
      fillchar(b,sizeof(b),0);
    end;
  for i:=1 to k do
    if q[i]=1 then
      writeln ('YES')
    else
      writeln ('NO');
end.
IT IS P1211
Posted by I am david. Tabo. 26 Oct 2002 19:25