|
|
вернуться в форумWhy WA on 8 test? What test is it? this is my program: program Tresh; const SIZE = 1000; var a : array[1..SIZE] of Byte; max : array[1..SIZE] of Longint; n : Longint; function MaxFrase (i, cur : Longint) : Longint; var j, curmax, curn : Longint; begin curmax := 0; if i+2 > n then begin MaxFrase := cur+a[i]; Exit; end; if max[i] <> 0 then MaxFrase := max[i] else begin for j := i+2 to n do begin curn := MaxFrase(j, cur+a[i]); if curn > curmax then curmax := curn; end; max[i] := curmax; MaxFrase := curmax; end; end; var ch, chpred : Char; cur : Byte; i : Longint; begin i := 1; FillChar(max, SizeOf(Longint)*SIZE, 0); while not Eof do begin Read(ch); if not (ch in ['a'..'z', 'A'..'Z']) then begin if cur <> 0 then begin a[i] := cur; Inc (i); end; cur := 0; end else begin { if ch <> chpred then} Inc (cur); chpred := ch end; end; if cur <> 0 then begin a[i] := cur; Inc (i); cur := 0; end; n := i-1; Writeln (MaxFrase(1, 0)) end. |
|
|