Pagini recente » Cod sursa (job #2066779) | Cod sursa (job #2619347) | Cod sursa (job #1313980)
#include<fstream>
#include<vector>
#include<iomanip>
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;
vector<double> PREC;
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);
}
double Sum;
Elem E;
double findMax(int b, int e) {
if(b == e) {
Sum = 0;
for(int i=0; i<=n-b; i++) {
E = dif(S[i+b], S[i]);
Sum = max(Sum, (double)E.c/E.t);
}
return Sum;
} else {
return max(findMax(b, (b+e)/2), findMax((b+e)/2+1, e));
}
}
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;
fout<<setprecision(20)<<findMax(l, u);
}