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 1203. Scientific Conference

What's wrong with my program,tell me please!!(WA)
Posted by Lucky 26 Jan 2003 18:46
program t1203;
const p=30000;
var a:array[1..p,1..2]of integer;
    b:array[0..30000]of integer;
    n,i,j,i1,t:integer;
procedure qsort(l,r:integer);
var j,i,x,y:integer;
begin
     i:=l;j:=r;
     x:=a[(l+r) div 2,2];
     repeat
           while a[i,2]<x do inc(i);
           while a[j,2]>x do dec(j);
           if i<=j then begin
              y:=a[i,2];a[i,2]:=a[j,2];a[j,2]:=y;
              y:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=y;
              inc(i);dec(j);
              end;
     until i>j;
     if l<j then qsort(l,j);
     if i<r then qsort(i,r);
     end;
begin
     readln(n);
     for i:=1 to n do read(a[i,1],a[i,2]);
     qsort(1,n);
     b[0]:=0; b[1]:=0; j:=1;
     for i:=1 to n do
         begin
         i1:=j;
         for j:=i1 to a[i,2] do b[j]:=b[i1];
         if b[a[i,1]-1]+1>b[a[i,2]] then b[a[i,2]]:=b[a[i,1]-1]+1;
         end;
     writeln(b[a[n,2]]);
end.
==========================
I can pass many inputs in my computer, But still WA