Cod sursa(job #2455123)

Utilizator BogdanRazvanBogdan Razvan BogdanRazvan Data 10 septembrie 2019 20:26:28
Problema Secventa 3 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.07 kb
#include <bits/stdc++.h>

using namespace std;


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

deque < double > dq;
int main()
{
    ios::sync_with_stdio(false);
    fin.tie(0);
    int n, mn, mx;
    fin >> n >> mn >> mx;
    f[n + 1] = 30005.0;
    for(int i = 1; i <= n; ++i) fin >> c[i];
    for(int i = 1; i <= n; ++i) fin >> t[i];
    for(int i = 1; i <= n; ++i) f[i] = 1.0 * c[i] / t[i];
    for(int i = 1; i <= n - mn + 1; ++i) nextt[i] = i + mn - 1;
    for(int i = n - mn; i >= 1; --i) {
        nextt[i] = nextt[i + 1];
        nextt[i] = min(i + mx - 1, nextt[i]);
        nextt[i] = min(nextt[i], n);
        int j = nextt[i] + 1;
        while(f[j] <= f[j + 1] && j <= n && j <= i + mx - 1) nextt[i] = j, ++j;
    }
    for(int i = 2; i <= n; ++i) f[i] = f[i - 1] + f[i];
    double sol = 0;
    for(int i = 1; i <= n - mn + 1; ++i)
        sol = max(sol, 1.0 * (f[nextt[i]] - f[i - 1]) / (nextt[i] - i + 1));
    fout << fixed << setprecision(10) << sol << "\n";
    return 0;
}