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 1134. Cards

my code easy, pls help me!!
Posted by Bobur 21 Apr 2008 21:32
   var
   y : array [0..1001] of boolean;
   a : array [1..1001] of integer;
   i, m, n : integer;

   procedure quicksort;
      procedure sort(l, r : integer);
        var
          i1, j1, x, w : integer;
        begin
        i1 := l;
        j1 := r;
        x := a[(l+r) div 2];
          repeat
            while  a[i1]<x do
              inc(i1);
            while  x<a[j1] do
              dec(j1);
            if i1 <= j1 then  begin  w := a[i1]; a[i1] := a[j1];  a[j1] := w;
                                   inc(i1);  dec(j1);     end;
          until i1 > j1;
        if l < j1 then sort(l, j1);
        if i1 < r then sort(i1, r);
        end;
     begin
     sort(1, m);
     end;{quicksort}

begin
   fillchar(y, sizeOf(y), true);
   read(n, m);
   if n>= m then begin
   for i := 1 to m do
   read(a[i]);
   quicksort;
   y[0] := false;
   for i := 1 to m do
     if y[a[i]] then y[a[i]] := false
     else
       if y[a[i]+1] then y[a[i]+1] := false
       else begin writeLn('NO');  halt; end;
   writeLn('YES');
   end
   else writeLn('NO');
end.
i've WA#3, thanks.