Cod sursa(job #2068704)

Utilizator AlexPop28Pop Alex-Nicolae AlexPop28 Data 18 noiembrie 2017 10:34:52
Problema Secventa 3 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <iostream>
#include <fstream>
#include <iomanip>
// (float)((sc[j]-sc[i-1])/(st[j]-st[i-1]))
void citire();
using namespace std;
ifstream f ("secv3.in");
ofstream g ("secv3.out");
int n, U, L, sc[30000], st[30000],i,j,x;
double aux, maxx=-1;
int main()
{
    citire();
    for(i=1; i<=n-L+1; i++)
    {
        for(j=i+L-1; j<=i+U-1 && j<=n; j++)
        {
            aux = (double)(sc[j] - sc[i-1])/(double)(st[j]-st[i-1]);
            if(aux > maxx)
                maxx=aux;
        }
    }
    g  << 0 << "."<<(int)(maxx*100);
    f.close();
    g.close();
}
void citire()
{
    f >> n >>L >> U;
    for(i=1; i<=n; i++)
        {
            f >> x;
            sc[i] = sc[i-1] + x;
            // sc e un vector de sume partiale pt costuri
        }
    for(i=1; i<=n; i++)
        {
            f >> x;
            st[i] = st[i-1] + x;
            // st e un vector de sume partiale pt timpi
        }
}