Pagini recente » Cod sursa (job #2869094) | Cod sursa (job #901522) | Cod sursa (job #2596634) | Cod sursa (job #1600099) | Cod sursa (job #1313951)
#include<fstream>
#include<vector>
using namespace std;
ifstream fin("secv3.in");
ofstream fout("secv3.out");
struct Elem {
int c, t;
Elem(int a, int b) {c = a; t = b;}
Elem() {}
};
vector<Elem> S;
int n, l, u;
Elem sum(const Elem &a, const Elem &b) {
return Elem(a.c+b.c, a.t+b.t);
}
Elem dif(const Elem &a, const Elem &b) {
return Elem(a.c-b.c, a.t-b.t);
}
int main() {
fin>>n>>l>>u;
int c, t;
S.resize(n+1);
S[0].c = S[0].t = 0;
for(int i=1; i<=n; i++) {
fin>>S[i].c;
S[i].c += S[i-1].c;
}
for(int i=1; i<=n; i++) {
fin>>S[i].t;
S[i].t += S[i-1].t;
}
Elem e;
double best = -1;
int i, j;
for(i=0; i<=n-u; i++)
for(j=i+l; j<=i+u; j++) {
e = dif(S[j], S[i]);
best = max(best, ((double)e.c/e.t));
}
for(; i<=n-l; i++)
for(j=i+1; j<=n; j++) {
e = dif(S[j], S[i]);
best = max(best, ((double)e.c/e.t));
}
fout<<best;
return 0;
}