Pagini recente » Cod sursa (job #99171) | Cod sursa (job #2136126) | Cod sursa (job #2593980) | Cod sursa (job #3174667) | Cod sursa (job #1301880)
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "secv3";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif
typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;
const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const double EPS = (1e-3);
const int NMAX = 100000 + 5;
int N, L, U;
int C[NMAX];
int T[NMAX];
double A[NMAX];
double S[NMAX];
double sol;
deque<int> DQ;
bool check(double x) {
int i;
for(i = 1; i <= N; i++) {
A[i] = C[i] - x * T[i];
S[i] = S[i - 1] + A[i];
}
DQ.resize(0);
for(i = L; i <= N; i++) {
while(!DQ.empty() && S[i - L] <= S[DQ.back()])
DQ.pop_back();
while(!DQ.empty() && i - DQ.front() + 1 > U)
DQ.pop_front();
DQ.push_back(i - L);
if(S[i] - S[DQ.front()] >= 0)
return 1;
}
return 0;
}
int main() {
int i;
double lo, mi, hi;
#ifndef ONLINE_JUDGE
freopen(inputFile.c_str(), "r", stdin);
freopen(outputFile.c_str(), "w", stdout);
#endif
scanf("%d%d%d", &N, &L, &U);
for(i = 1; i <= N; i++)
scanf("%d", &C[i]);
for(i = 1; i <= N; i++)
scanf("%d", &T[i]);
for(lo = 0.0, hi = 10000.0; fabs(lo - hi) > EPS; ) {
mi = (lo + hi) / 2.0;
if(check(mi)) {
lo = mi;
sol = mi;
} else
hi = mi;
}
printf("%.2f\n", sol);
return 0;
}