Pagini recente » Cod sursa (job #3223838) | Cod sursa (job #2171214) | Cod sursa (job #3147556) | Cod sursa (job #1400725) | Cod sursa (job #2607506)
#include <stdio.h>
#include <ctype.h>
#define NMAX 30003
#define EPS 0.001
#define MAXVAL 33554432
#define X 1000
#define MAXLOG10 10
#define BUFSIZE (128 * 1024)
using namespace std;
int p10[MAXLOG10 + 1] = { 0, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
int rpos; char rbuf[BUFSIZE];
static inline void initRead() {
rpos = BUFSIZE - 1;
}
static inline char readChar() {
if ( !(rpos = (rpos + 1) & (BUFSIZE - 1)) )
fread( rbuf, 1, BUFSIZE, stdin );
return rbuf[rpos];
}
int readInt() {
int ch, res = 0;
while ( isspace( ch = readChar() ) );
do
res = 10 * res + ch - '0';
while ( isdigit( ch = readChar() ) );
return res;
}
int vcost[NMAX], vtimp[NMAX];
float v[X + 3];
int main() {
freopen ( "secv3.in", "r", stdin );
freopen ( "secv3.out", "w", stdout );
int n, lmin, lmax, i, scost, stimp, k;
float r, mij;
initRead();
n = readInt();
lmin = readInt();
lmax = readInt();
for ( i = 0; i < n; i++ )
vcost[i] = readInt();
for ( i = 0; i < n; i++ )
vtimp[i] = readInt();
r=0;
for ( k = lmin; k <= lmax; k+=2 ) {
scost = stimp = 0;
for ( i = 0; i < k; i++ ) {
scost += vcost[i];
stimp += vtimp[i];
}
mij = (float) scost / stimp;
for ( i = k; i < n; i++ ){
scost = scost - vcost[i - k] + vcost[i];
stimp = stimp - vtimp[i - k] + vtimp[i];
if ( (float) scost / stimp > mij )
mij = (float) scost / stimp;
}
if ( r < mij )
r = mij;
}
printf ( "%f\n", r );
return 0;
}