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 1410. Crack

Why WA on 8 test? What test is it?
Posted by Kolobov_Oleg 3 Feb 2009 16:43
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.