Cod sursa(job #1333105)

Utilizator cautionPopescu Teodor caution Data 2 februarie 2015 20:07:49
Problema Secventa 3 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <cstdio>
using namespace std;
int main()
{
    freopen("secventa3.in", "r", stdin);
    freopen("secventa3.out", "w", stdout);
    long c[30010], t[30010], aux, bot_limit, top_limit;
    long n, u, l;
    double max=0, aux2;
    scanf("%ld %ld %ld", &n, &u, &l);
    c[0]=0;
    t[0]=0;
    for(long i=1; i<=n; ++i)
    {
        scanf("%ld", &aux);
        c[i]=c[i-1]+aux;
    }
    for(long i=1; i<=n; ++i)
    {
        scanf("%ld", &aux);
        t[i]=t[i-1]+aux;
    }
    for(long i=1; i<=n; ++i)
    {
        bot_limit=i+u-1;
        top_limit=i+l-1;
        if(bot_limit>n) bot_limit=n;
        if(top_limit>n) top_limit=n;
        for(long j=bot_limit; j<=top_limit; ++j)
        {
            aux2=((long double)(c[j]-c[i-1]))/(t[j]-t[i-1]);
            if(aux2>max) max=aux2;
        }
    }
    printf("%.2f\n", max);
    fclose(stdin); fclose(stdout);
    return 0;
}