Pagini recente » Cod sursa (job #1054498) | Cod sursa (job #808712) | Cod sursa (job #2980007) | Cod sursa (job #3149174) | Cod sursa (job #2109396)
#include <fstream>
#include <iomanip>
using namespace std;
ifstream in ("secv3.in");
ofstream out ("secv3.out");
int cost[30001],timp[30001];
int n;
double val(int lung)
{
double ma=0,x;
int i;
for(i=lung; i<=n; i++)
{
x=(1.00*cost[i]-cost[i-lung])/(1.00*timp[i]-timp[i-lung]);
if(x>ma)
ma=x;
}
return ma;
}
int main()
{
int l,u;
in>>n>>l>>u;
int i;
for(i=1;i<=n;i++)
in>>cost[i],cost[i]+=cost[i-1];
for(i=1;i<=n;i++)
in>>timp[i],timp[i]+=timp[i-1];
int lg;
double ma=0;
double x;
for(lg=l;lg<=u;lg++)
{
x=val(lg);
if(ma<x)
ma=x;
}
out<<fixed<<setprecision(2)<<ma;
return 0;
}