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 1119. Metro

Help!Why I got WA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!????????????
Posted by Li Xun 16 Apr 2003 18:26
type
    list=array[1..2]of integer;
var
   a:array[0..100]of list;
   f1:list;
   f:array[0..100]of longint;
   i,j,k,m,n,max:longint;
begin
     fillchar(a,sizeof(a),0);
     readln(m,n);
     read(k);
     for i:=1 to k do
         read(a[i][1],a[i][2]);
     for i:=1 to k-1 do
         for j:=1 to k-i do
             if (a[j][1]>a[j+1][1]) or (a[j][2]>a[j+1][2]) then begin
                f1:=a[j];
                a[j]:=a[j+1];
                a[j+1]:=f1;
             end;
     f[0]:=0;
     for i:=1 to k do begin
         max:=0;
         for j:=0 to i do begin
             if (a[j][1]<a[i][1]) and (a[j][2]<a[i][2]) then if f[j]
+1>max then max:=f[j]+1;
         end;
         f[i]:=max;
     end;
     writeln((m+n-2*f[k]+sqrt(2)*f[k])*100:0:0);
end.