Cod sursa(job #2464742)

Utilizator bluestorm57Vasile T bluestorm57 Data 28 septembrie 2019 21:10:13
Problema Secventa 3 Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("secv3.in");
ofstream g("secv3.out");

const int NMAX = 30005;
int n,mn,mx,t[NMAX],c[NMAX];
double ans;

int main(){
    int i,j;
    f >> n >> mn >> mx;
    for(i = 1 ; i <= n ; i++)
        f >> c[i];
    for(i = 1 ; i <= n ; i++)
        f >> t[i];

    for(i = 2 ; i <= n ; i++){
        c[i] += c[i - 1];
        t[i] += t[i - 1];
    }

    ans = c[mn] * 1.0 / (t[mn] * 1.0);
    i = 1;
    for(j = mn + 1 ; j <= n ; j++){
        if(j - i == mx - 1)
            i++;
        if(t[j] - t[i - 1])
            ans = max(ans, double((c[j] - c[i - 1]) * 1.0 / ((t[j] - t[i - 1]) * 1.0)));
    }
    g << fixed << setprecision(5) << ans;
    return 0;
}