Pagini recente » Cod sursa (job #611786) | Cod sursa (job #2254186) | Cod sursa (job #2075196) | Cod sursa (job #2537206) | Cod sursa (job #60440)
Cod sursa(job #60440)
#include <cstdio>
#define max 30000
FILE *in = fopen("secv3.in","r"), *out = fopen("secv3.out","w");
struct sir
{
int cost, timp;
int lng;
};
int n, l, u;
int a[max];
int b[max];
sir c[max];
void read()
{
fscanf(in, "%d %d %d", &n, &l, &u);
for ( int i = 0; i < n; ++i )
fscanf(in, "%d", &a[i]);
for ( int i = 0; i < n; ++i )
fscanf(in, "%d", &b[i]);
}
int main()
{
read();
double eps = 0.0001;
c[0].cost = a[0];
c[0].timp = b[0];
c[0].lng = 1;
double rez = -1.0;
for ( int i = 1; i < n; ++i )
{
if ( ((double)(c[i-1].cost + a[i]) / (c[i-1].timp + b[i]) - (double)a[i] / b[i]) > eps )
{
c[i].cost = c[i-1].cost + a[i];
c[i].timp = c[i-1].timp + b[i];
c[i].lng = c[i-1].lng + 1;
}
else
{
c[i].cost = a[i];
c[i].timp = b[i];
c[i].lng = 1;
}
if ( ((double)c[i].cost / c[i].timp - rez) > eps && c[i].lng >= l && c[i].lng <= u )
rez = (double)c[i].cost / c[i].timp;
}
fprintf(out, "%.2lf\n", rez);
return 0;
}