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

Please Help me with program 1134. I know, that my program is wrong! But i'm don't understand why??? Please give me some tests, on which my program is wrong!
Posted by Reshetnikov Eugeny 11 Dec 2002 00:16
This is my program:
program p1134;

const MaxN    = 1000;

var   N,M,X,i : Integer;
      C       : Array[0..MaxN]of Integer;
      Yes     : Boolean;

begin
  FillChar(C,SizeOf(C),0);
  Read(N,M);
  if (M>0) and (M<=N) then Yes:=true else Yes:=false;
  for i:=1 to M do begin
    Read(X);
    if X>N then Yes:=false else C[X]:=C[X]+1;
  end;
  if (C[0]>1) or (C[N]>1) then Yes:=false;
  for i:=1 to N-1 do begin
    if C[i]>2 then
      Yes:=false else
    if (C[i]=2) and ((C[i-1]>0) or (C[i+1]>0)) then
      Yes:=false;
  end;
  if Yes then Writeln('YES') else Writeln('NO');
end.