Pagini recente » Cod sursa (job #2288772) | Cod sursa (job #3208011) | Cod sursa (job #958234) | Cod sursa (job #753873) | Cod sursa (job #2557051)
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
ifstream fin("secv3.in");
ofstream fout("secv3.out");
int n, mi, ma;
double top[30041], bot[30041];
void read(){
fin >> n >> mi >> ma;
for(int i = 1; i <= n; ++i){
fin >> top[i];top[i] += top[i-1];
}
for(int i = 1; i <= n; ++i){
fin >> bot[i];bot[i] += bot[i-1];
}
}
double frac(int lt, int rt){
return (top[rt]-top[lt-1]) / (bot[rt]-bot[rt-1]);
}
double maxi = 0;
void solve(){
int lt = 1;
for(int rt = mi; rt <= n; ++rt){
if(rt-lt >= ma){
lt++;
}
double obg = frac(rt-mi+1, rt);
double ext = frac(lt, rt);
if(obg > ext){
lt = rt-mi+1;
maxi = max(maxi, obg);
}else{
maxi = max(maxi, ext);
}
}
fout << setprecision(6) << fixed;
fout << maxi;
}
int main(){
read();
solve();
return 0;
}