Cod sursa(job #2222591)

Utilizator cezar_titianuTitianu Cezar cezar_titianu Data 17 iulie 2018 13:50:40
Problema Secventa 3 Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.06 kb
#include <fstream>

using namespace std;

ifstream fin("secv3.in");
ofstream fout("secv3.out");

int nrnr, nr1, nr2;

int vecv[30000][2];
int vect[30000][2];

double sav, maxi = 0.0;

int main()
{
    fin >> nrnr >> nr1 >> nr2;
    for(int index = 0; index < nrnr; index++){
        fin >> vecv[index][0];
    }
    for(int index = 0; index < nrnr; index++){
        fin >> vect[index][0];
        sav = (double)vecv[index][0] / (double)vect[index][0];
        if(sav > maxi){
            maxi = sav;
        }
    }
    for(int index = 1; index < nrnr; index++){
        for(int index2 = 0; index2 < nrnr - index; index2++){
            vecv[index2][index % 2] = vecv[index2][(index + 1) % 2] + vecv[index2 + 1][(index + 1) % 2];
            vect[index2][index % 2] = vect[index2][(index + 1) % 2] + vect[index2 + 1][(index + 1) % 2];
            sav = (double)vecv[index2][index % 2] / (double)vect[index2][index % 2];
            if(sav > maxi){
                maxi = sav;
            }
        }
    }
    fout << maxi;
    return 0;
}