Cod sursa(job #1015884)

Utilizator ELHoriaHoria Cretescu ELHoria Data 25 octombrie 2013 13:19:46
Problema Secventa 3 Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <fstream>
 
using namespace std;
 
ifstream fin("secv3.in");
ofstream fout("secv3.out");
 
const int nmax = 30002;
int N, L, U;
int c[nmax], t[nmax];
double ans;
 
int main()
{
    fin>>N>>L>>U;
    for(int i = 1;i <= N;++i) {
        fin>>c[i];
		c[i] += c[i - 1];
	}

    for(int i = 1;i <= N;++i) {
        fin>>t[i];
		t[i] += t[i - 1];
	}
     
	for(int i = 1;i + L <= N;++i) {
		int sum[2] = {0,0};
		for(int j = i + L - 1;j <= N && j - i + 1 <= U;j++) {
			ans = max(ans,1.0*(c[j] - c[i - 1])/(t[j] - t[i - 1]));
		}
	}
	fout.precision(3);
    fout<<fixed<<ans;
    return 0;
}