Cod sursa(job #2890852)

Utilizator BogdanRazvanBogdan Razvan BogdanRazvan Data 16 aprilie 2022 20:25:03
Problema Secventa 3 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <bits/stdc++.h>

using namespace std;


ifstream fin ("secv3.in");
ofstream fout ("secv3.out");
int c[30005], t[30005];
double f[30005];

deque < int > dq;
int main()
{
    ios::sync_with_stdio(false);
    fin.tie(0);

    int n, mn, mx;
    fin >> n >> mn >> mx;
    for(int i = 1; i <= n; ++i) fin >> c[i];
    for(int i = 1; i <= n; ++i) fin >> t[i];
    for(int i = 2; i <= n; ++i) {
            c[i] = c[i - 1] + c[i];
            t[i] = t[i - 1] + t[i];
    }
    double sol = 1.0 * c[mn] / (1.0 * t[mn]);
    int j = 1;
    for(int i = mn + 1; i <= n; ++i) {
        if(i - j == mx - 1) ++j;
        double ans1 = 1.0 * (c[i] - c[j - 1]) / (1.0 * (t[i] - t[j - 1]));
        double ans2 = 1.0 * (c[i] - c[i - mn]) / (1.0 * (t[i] - t[i - mn]));
        if(ans2 > ans1)
            j = i - mn + 1;
        sol = max(sol, max(ans1, ans2));
    }
    fout << fixed << setprecision(10) << sol;
    return 0;
}