Pagini recente » Cod sursa (job #341451) | Cod sursa (job #305728) | Cod sursa (job #518944) | Cod sursa (job #222880) | Cod sursa (job #2041144)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("secv3.in");
ofstream fout("secv3.out");
const int NMax = 30005;
const int EPS = 0.001;
int L, U, N;
int c[NMax], t[NMax];
void Read()
{
fin >> N >> L >> U;
int x;
for(int i=1; i<=N; ++i)
{
fin >> x;
c[i] = x + c[i-1];
}
for(int i=1; i<=N; ++i)
{
fin >> x;
t[i] = x + t[i-1];
}
}
void Greedy()
{
double rez = 1.0 * c[L] / t[L];
int j = 1;
for(int i = L+1; i <= N ; ++i)
{
if(i - L == U)
++j;
double t1 = 1.0 * (c[i] - c[j-1]) / (t[i] - t[j-1]);
double t2 = 1.0 * (c[i] - c[i-L]) / (t[i] - t[i-L]);
if(t1 - t2 < EPS)
{
t1 = t2;
j = i - L + 1;
}
rez = max(rez, t1);
}
fout << rez;
}
using namespace std;
int main()
{
Read();
Greedy();
return 0;
}