Pagini recente » Cod sursa (job #2713948) | Cod sursa (job #1390077) | Cod sursa (job #481139) | Cod sursa (job #2478083) | Cod sursa (job #2259652)
#include <fstream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
ifstream in("secv3.in");
ofstream out("secv3.out");
int main()
{
int n, lim_st, lim_dr;
in >> n >> lim_st >> lim_dr;
vector<double> cost(n + 1);
vector<double> timp(n + 1);
for (int i = 1; i <= n; i++)
{
int x;
in >> x;
cost[i] = cost[i - 1] + x;
}
for (int i = 1; i <= n; i++)
{
int x;
in >> x;
timp[i] = timp[i - 1] + x;
}
double rez = cost[lim_st] / timp[lim_st];
int k = 1;
for (int i = lim_st + 1; i <= n; i++)
{
if (i - lim_st == lim_dr)
k++;
double a = (cost[i] - cost[k - 1]) / (timp[i] - timp[k - 1]);
double b = (cost[i] - cost[i - lim_st]) / (timp[i] - timp[i - lim_st]);
if (b > a)
k = i - lim_st + 1;
rez = max(rez, max(a, b));
}
out << fixed << setprecision(2) << rez;
return 0;
}