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

Discussion of Problem 1021. Sacrament of the Sum

I'm Sure my prog is correct, but it got WA#4!!! Plz help or give test.
Posted by Akshin 8 Apr 2005 18:54
it is very simple problem but my prog got wa, i dont know why?!


const
  z:array[1..2] of byte = (2,1);
var
  a:array[-32768..32767] of byte;
  s:string;
  b:integer;
  i,n:longint;

begin
{  assign(input,'in.in');
  reset(input);}

  fillchar(a,sizeof(a),0);

  readln(n);
  for i:=1 to n do
  begin
    readln(b);
    a[b]:=1;
  end;

  readln(n);
  for i:=1 to n do
  begin
    readln(b);
    if (b=5000) and (a[b]=1) then
    a[b]:=3 else a[b]:=2;
  end;

{  close(input); }

  s:='NO';
  for i:=-32768 to 32767 do
  if a[i]<>0 then
  begin
    if a[i]=3 then
    begin
      s:='YES';
      break;
    end;
    if a[10000-i]=z[a[i]] then
    begin
      s:='YES';
      break;
    end
  end;

  writeln(s);
end.
Re: I'm Sure my prog is correct, but it got WA#4!!! Plz help or give test.
Posted by Kit 8 Apr 2005 21:21
Try this:
1
3000
2
7000
3000.
Your answer is NO;)
Re: I'm Sure my prog is correct, but it got WA#4!!! Plz help or give test.
Posted by lengyue2005 7 May 2005 11:34

const
  max=4268;
var
  a:array[-max..max] of 0..1;
  n,n2,i,j:longint;
  procedure rea;
    var
      i,j,p:longint;
      t:boolean;
    begin
      fillchar(a,sizeof(a),0);
      t:=false;
      readln(n);
      for i:=1 to n do
        begin
          readln(p);
          a[10000-p]:=1;
        end;
      readln(n2);
      for i:=1 to n2 do
        begin
          readln(p);
          if a[p]=1
            then t:=true;
        end;
      if not t
        then writeln('NO')
        else writeln('YES');
    end;
begin
  while not eof do
    begin
      rea;
    end;
end.