Cod sursa(job #1291)

Utilizator kimhioCobarzan Petrut kimhio Data 13 decembrie 2006 10:58:37
Problema Secventa 3 Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.77 kb
program sec3;
type ta=array [0..1000] of longint;
var scost,stimp,cost,timp:ta;
    n,l,u,i,j:integer;
    f:text;
    intr,frac,co,ti:longint;
    max:real;
begin {pp}
assign(f,'secv3.in');reset(f);
readln(f,n,l,u);
scost[0]:=0;
for i:=1 to n do
    begin
    read(f,cost[i]);
    scost[i]:=scost[i-1]+cost[i];
    end;
readln(f);
stimp[0]:=0;
for i:=1 to n do
    begin
    read(f,timp[i]);
    stimp[i]:=stimp[i-1]+timp[i];
    end;
close(f);
max:=0;
for i:=l to n do
    for j:=0 to u-l do
        begin
        co:=scost[i+j]-scost[i-1];
        ti:=stimp[i+j]-stimp[i-1];
        if (co/ti)>max then max:=co/ti;
        end;
intr:=trunc(max);
frac:=trunc((max-intr)*100);
assign(f,'secv3.out');rewrite(f);
write(f,intr,'.',frac);
close(f);
end.