Pagini recente » Cod sursa (job #3197683) | Cod sursa (job #690268) | Cod sursa (job #3163900) | Cod sursa (job #973777) | Cod sursa (job #2196428)
#include <cstdio>
#include <iostream>
using namespace std;
int n, l, u, i, j, nr;
double rez, now, ante, costuri[30005], times[30005];
void citire()
{
scanf("%d %d %d\n",&n, &l, &u);
for(i = 1; i <= n; i++)
{
scanf("%d ", &nr);
costuri[i] = costuri[i-1] + nr;
}
for(i = 1; i <= n; i++)
{
scanf("%d ", &nr);
times[i] = times[i-1] + nr;
}
}
int main()
{
freopen("secv3.in","r",stdin);
freopen("secv3.out","w",stdout);
citire();
rez = costuri[l] / times[l];
j = 1;
for(i = l+1; i <= n; i++)
{
if(i - l == u)
j++;
ante = (costuri[i] - costuri[j-1]) / (times[i] - times[j-1]);
now = (costuri[i] - costuri[i-l]) / (times[i] - times[i-l]);
if(ante < now)
{
ante = now;
j = i - l + 1;
}
rez = max(rez, ante);
}
printf("%.2lf", rez);
return 0;
}