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

---Problem 1134--- What's wrong with my code.
Posted by Vitaliy Surovyi 13 Aug 2003 15:59
I tried different tests and i don't understand why WA.

Var
   A,B : Array [0..1001] Of Integer;
   N,K,I : Longint;
   Fl : Boolean;

Begin
Read(N);Read(K);
If K>N Then Begin Writeln('NO');Halt;End;
For I:=1 To K Do Begin Read(A[I]);
If A[I]>N Then Begin Writeln('NO');Halt;End;
Inc(B[A[I]]);
End;

If (B[0]=1) And (B[1]=2) Then Begin Writeln('NO');Halt;End;
If (B[N-1]=2) And (B[N]=1) Then Begin Writeln('NO');Halt;End;

For I:=0 To N Do Begin
If B[I]=0 Then Fl:=True;
If (B[I]=2) And not Fl Then Begin Writeln('NO');Halt;End;
End;

For I:=1 To N Do
If (B[I-1]=2) And (B[I]=2) Then Begin Writeln('NO');Halt;End;
Writeln('YES');
End.