Cod sursa(job #2533678)

Utilizator Florinos123Gaina Florin Florinos123 Data 29 ianuarie 2020 15:58:06
Problema Secventa 3 Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.86 kb
#include <fstream>
#include <iomanip>

using namespace std;

ifstream f ("secv3.in");
ofstream g ("secv3.out");

int n, i, low, up, lg, x, st, dr;
double maxim, raport;
long long cost[30001], timp[30001];

int main()
{
   f >> n >> low >> up;
    for (i=1; i<=n; i++)
    {
        f >> x;
        cost[i] = cost[i-1] + x;
    }
    for (i=1; i<=n; i++)
    {
        f >> x;
        timp[i] = timp[i-1] + x;
    }
    lg = low;
     while (lg <= up)
     {
         st = 1;
         dr = lg - 1;
          while (dr <= n)
          {
              raport = (cost[dr] - cost[st-1]);
              raport /= (timp[dr] - timp[st-1]);
               if (raport > maxim)
                  maxim = raport;
               st ++;
               dr ++;
          }
        lg ++;
     }
  g << fixed << setprecision(2) << maxim;

    return 0;
}