Pagini recente » Cod sursa (job #2287377) | Cod sursa (job #2438548) | Cod sursa (job #3030846) | Cod sursa (job #663740) | Cod sursa (job #1833958)
#include <cstdio>
using namespace std;
int n, L, U, i, j;
int cost[30002], time[30002], sumCost[30002], sumTime[30002];
double ratio, max;
int main()
{
freopen("secv3.in", "r", stdin);
freopen("secv3.out", "w", stdout);
scanf("%d %d %d", &n, &L, &U);
for(i = 0; i < n; i++)
scanf("%d", &cost[i]);
for(i = 0; i < n; i++)
scanf("%d", &time[i]);
for(i = 0; i < n; i++)
{
for(j = 0; j < U && (i + j) < n; j++)
{
sumCost[i] += cost[i + j];
sumTime[i] += time[i + j];
}
if(sumTime[i] != 0)ratio = (double) ((double)sumCost[i] / (double)sumTime[i]);
if(ratio > max) max = ratio;
}
U--;
while(U >= L)
{
for(i = 0; i <= n; i++)
if((i + U) < n)
{
sumCost[i] -= cost[i + U];
sumTime[i] -= time[i + U];
if(sumTime[i] != 0) ratio = (double) ((double)sumCost[i] / (double)sumTime[i]);
if(ratio > max) max = ratio;
}
U--;
}
printf("%.2f\n", max);
return 0;
}