Cod sursa(job #129705)

Utilizator ProtomanAndrei Purice Protoman Data 29 ianuarie 2008 21:58:03
Problema Secventa 3 Scor 50
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.11 kb
var f1,f2:text;
    i,n,sc,st,m,l,u,spt,spc,x:longint;
    s,sp,mx:double;
    c,t:array[-30010..30010] of integer;
begin
        assign(f1,'secv3.in');
        reset(f1);
        assign(f2,'secv3.out');
        rewrite(f2);
        read(f1,n,l,u);
        for i:=1 to n do
                read(f1,c[i]);
        for i:=1 to n do
                read(f1,t[i]);
        for i:=1 to l-1 do
        begin
                sc:=sc+c[i];
                st:=st+t[i];
        end;
        m:=l-1;
        for i:=l to n do
        begin
                sc:=sc+c[i]-c[i-u];
                st:=st+t[i]-t[i-u];
                s:=sc/st;
                spc:=sc;
                spt:=st;
                for x:=u-1 downto l do
                begin
                        spc:=spc-c[i-x];
                        spt:=spt-t[i-x];
                        sp:=spc/spt;
                        if sp>s then
                                s:=sp;
                end;
                if s>mx then
                        mx:=s;
        end;
        writeln(f2,mx:0:7);
        close(f1);
        close(f2);
end.