Cod sursa(job #2891259)

Utilizator matthriscuMatt . matthriscu Data 17 aprilie 2022 23:43:12
Problema Secventa 3 Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <bits/stdc++.h>
using namespace std;

#define name "secv3"
#define NMAX 30005
#define EPS 1e-3

int main()
{
	FILE *f = fopen(name ".in", "r");

	int n, l, u;
	fscanf(f, "%d%d%d", &n, &l, &u);

	int c[NMAX], t[NMAX];
	c[0] = t[0] = 0;
	for (int i = 1; i <= n; ++i) {
		fscanf(f, "%d", &c[i]);
		c[i] += c[i - 1];
	}
	
	for (int i = 1; i <= n; ++i) {
		fscanf(f, "%d", &t[i]);
		t[i] += t[i - 1];
	}
	
	fclose(f);
	
	double ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = i + l - 1; j <= i + u - 1; ++j)
			ans = max(1.0 * (c[j] - c[i - 1]) / (t[j] - t[i - 1]), ans);

	f = fopen(name ".out", "w");
	fprintf(f, "%lf\n", ans);
	fclose(f);
}