|  | 
|  | 
| вернуться в форум | WHY my O(n^2) program gives WA#3!! plz help!! Послано Bobur  24 ноя 2008 01:27program Project1;
 {$APPTYPE CONSOLE}
 
 uses
 SysUtils;
 
 var
 s : array [0..105, 0..105] of integer;
 i, j, max, max1 : integer;
 x, n : shortint;
 q : boolean;
 
 begin
 max := -100;
 max1 := -100;
 q := false;
 read(n);
 for i := 0 to n do
 begin
 s[0, i] := 0;
 s[i, 0] := 0;
 end;
 for i := 1 to n do
 for j := 1 to n do
 begin
 read(x);
 if x >= 0 then q := true;
 if max1 < x then max1 := x;
 s[i, j] := s[i-1,j] + s[i,j-1] + x - s[i-1,j-1];
 if s[i, j] > max then max := s[i, j];
 if s[i, j] < 0 then s[i, j] := 0;
 end;
 if q then  writeLn(max)
 else writeLn(max1);
 end.
Re: WHY my O(n^2) program gives WA#3!! plz help!! 3123
 456
 789
 
 use this matrix to create simple test
 
 for example
 3
 1 2 3
 4 -55 6
 7 8 9
 
 end etc...
 | 
 | 
|