|
|
back to boardCommon BoardPlease 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! 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. |
|
|