Cod sursa(job #2330293)

Utilizator andreisontea01Andrei Sontea andreisontea01 Data 28 ianuarie 2019 10:49:02
Problema Secventa 3 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 30005;

int c[MAXN], t[MAXN];

int main()
{
    ifstream fin("secv3.in");
    ofstream fout("secv3.out");
    int n, l, u;
    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];
    }
    int st = 0;
    double ans = 0.00;
    for(int i = 1; i <= n; ++i){
        if(st < i - u)
            st++;
        if(i >= l){
            if((c[i] - c[i - l]) * (t[i] - t[st]) > (c[i] - c[st]) * (t[i] - t[i - l]))
                st = i - l;
            ans = max(ans, 1.000 * (c[i] - c[st]) / (t[i] - t[st]));
        }
    }
    fout << fixed << setprecision(2) << ans;
    return 0;
}