Cod sursa(job #714374)

Utilizator ELHoriaHoria Cretescu ELHoria Data 15 martie 2012 18:18:24
Problema Secventa 3 Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <fstream>
#include <iomanip>

using namespace std;

ifstream fin("secv3.in");
ofstream fout("secv3.out");

int N , L , U , c[30005] , t[30005];
double ans;

int main()
{
	fin>>N>>U>>L;
	for(int i = 1;i <= N;++i)
		fin>>c[i];
	for(int i = 1;i <= N;++i)
		fin>>t[i];
	
	for(int i = U;i <= N;++i)
	{
		double a = 0 , b = 0;
		for(int j = i;j >= i - L && j >= 1;--j) {
			a+=c[i] , b+=t[i];
			if(i - j >= U) ans = max(ans,a/b);
		}
	}
	fout<<fixed<<setprecision(2)<<ans;
	return 0;
}