Cod sursa(job #2631373)

Utilizator PatrickCplusplusPatrick Kristian Ondreovici PatrickCplusplus Data 30 iunie 2020 11:04:04
Problema Secventa 3 Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <bits/stdc++.h>

using namespace std;

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

const int nmax = 30000;
int n, l, u, a[nmax + 5], b[nmax + 5];
double ans = 0;

int main()
{
    fin >> n >> l >> u;
    for (int i = 1; i <= n; ++i)
    {
        fin >> a[i];
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= n; ++i)
    {
        fin >> b[i];
        b[i] += b[i - 1];
    }
    for (int i = l; i <= u; ++i)
    {
        for (int j = i; j <= n; ++j)
        {
            ans = max(ans, (a[j] - a[j - i]) / (double)(b[j] - b[j - i]));
        }
    }
    fout << fixed << setprecision(2) << ans;
    fin.close();
    fout.close();
    return 0;
}