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:28
var m,n,k,i,j,max,s:longint;
    ma:array[0..200] of longint;
    a:array[0..200,1..2] of longint;
begin
  read(n,m,k);
  for i:=1 to k do read(a[i,1],a[i,2]);
  for i:=1 to k-1 do
    for j:=i+1 to k do
      if (a[i,1]>a[j,1])or((a[i,1]=a[j,1])and(a[i,2]>a[j,2]))
        then begin
               s:=a[i,1]; a[i,1]:=a[j,1]; a[j,1]:=s;
               s:=a[i,2]; a[i,2]:=a[j,2]; a[j,2]:=s
             end;
  for i:=k downto 1 do
    begin
      max:=0;
      for j:=i+1 to k do
        if (a[j,1]>a[i,1])and(a[j,2]>a[i,2])and(ma[j]>max) then
max:=ma[j];
      ma[i]:=max+1
    end;
  writeln(round((m+n-2*ma[1]+sqrt(2)*ma[1])*100))
end.