Pagini recente » Cod sursa (job #632779) | Cod sursa (job #2922994) | Cod sursa (job #753196) | Cod sursa (job #430112) | Cod sursa (job #1992444)
#include <iostream>
#include <fstream>
#include <deque>
#include <iomanip>
#define N 30005
using namespace std;
ifstream f("secv3.in");
ofstream g("secv3.out");
double timp[N],cost[N],rez;
int n,l,u;
deque<int> pos;
double curent(int i)
{
return ((cost[i]-cost[pos.front()])/(timp[i]-timp[pos.front()]));
}
bool cond(int i)
{
return (timp[i]-timp[pos.back()]>cost[i]-cost[pos.back()]);
}
void citire()
{
for(int i=1;i<=n;++i)
{
f>>cost[i];
cost[i]+=cost[i-1];
}
for(int i=1;i<=n;++i)
{
f>>timp[i];
timp[i]+=timp[i-1];
}
}
int main()
{
f>>n>>l>>u;
citire();
for(int i=1;i<l;++i)
{
pos.push_back(i);
}
pos.push_front(0);
for(int i=l;i<=n;++i)
{
while(!pos.empty() && i-pos.front()>u)
{
pos.pop_front();
}
while(!pos.empty() && cond(i) && i-pos.back()<=u-l)
{
pos.pop_back();
}
rez=max(rez,curent(i));
pos.push_back(i);
}
g<<fixed<<setprecision(5)<<rez;
return 0;
}