Pagini recente » Cod sursa (job #2074542) | Cod sursa (job #2374103) | Cod sursa (job #1335149) | Cod sursa (job #60369) | Cod sursa (job #922461)
Cod sursa(job #922461)
#include<cstdio>
using namespace std;
#define MAX 30001
int N , L , U , c[MAX] , t[MAX], best_sum , best_t , len , sum , ti;
double sol;
void citire();
void solve();
void tipar();
int main()
{
citire();
solve();
tipar();
return 0;
}
void citire()
{
freopen("secv3.in" , "r" , stdin );
scanf("%d%d%d" , &N , &L ,&U );
for( int i = 1 ; i <= N ; ++i )
scanf("%d" , &c[i] );
for( int i = 1 ; i <= N ; ++i )
scanf("%d" , &t[i]);
}
void solve()
{
for(int i = 1 ; i < L ; ++i)
{
sum+=c[i];
ti+=t[i];
}
len = U;
for(int i = L ; i <= N ; ++i )
{
sum+=c[i];sum-=c[i-L];
ti+=t[i];ti-=t[i-L];
if((double)((best_sum+c[i])/(best_t+t[i]))-(double)(sum/ti) > 0&& len <U)
{
len++;
best_sum+=c[i];
best_t+=t[i];
}
else
{
best_sum = sum;
best_t = ti;
len = L;
}
if(sol < (double)best_sum/best_t)
sol = (double)best_sum/best_t;
}
}
void tipar()
{
freopen("secv3.out" , "w" , stdout );
printf("%lf" , sol);
}