RT
我枯了
我感觉我真没写挂,精度爆炸
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define R register
#define LL long long
const int inf = 0x3f3f3f3f;
const int N = 2000 + 5;
const double eps = 1e-9;
inline int read() {
char a = getchar(); int x = 0,f = 1;
for(;a > '9' || a < '0';a = getchar()) if(a == '-') f = -1;
for(;a >= '0' && a <= '9'; a = getchar()) x = x * 10 + a - '0';
return x * f;
}
int n, a, b;
long double p[N], u[N];
long double f[N];
int cnt1[N], cnt2[N];
inline bool Check(double v1,double v2) {
memset(f, 0, sizeof(f));
memset(cnt1, 0, sizeof(cnt1));
memset(cnt2, 0, sizeof(cnt2));
for(R int i = 1;i <= n; i ++) {
f[i] = f[i - 1];
cnt1[i] = cnt1[i - 1];
cnt2[i] = cnt2[i - 1];
if(f[i - 1] + p[i] - v1 > f[i]) {
f[i] = f[i - 1] + p[i] - v1;
cnt1[i] = cnt1[i - 1] + 1;
cnt2[i] = cnt2[i - 1];
}
if(f[i - 1] + u[i] - v2 > f[i]) {
f[i] = f[i - 1] + u[i] - v2;
cnt1[i] = cnt1[i - 1];
cnt2[i] = cnt2[i - 1] + 1;
}
if(f[i - 1] + p[i] + u[i] - p[i] * u[i] - v1 - v2 > f[i]) {
f[i] = f[i - 1] + p[i] + u[i] - p[i] * u[i] - v1 - v2;
cnt1[i] = cnt1[i - 1] + 1;
cnt2[i] = cnt2[i - 1] + 1;
}
}
return cnt2[n] <= b;
}
long double tl;
inline bool check(double md) {
long double l = 0, r = 1;
for(R int i = 1; i <= 50; i ++) {
long double mid = (l + r) / 2;
if(Check(md, mid)) r = mid;
else l = mid;
}
tl = l;
return cnt1[n] <= a;
}
int main() {
freopen("a.in","r",stdin);
freopen("b.out","w",stdout);
n = read(); a = read(); b = read();
for(R int i = 1; i <= n; i ++) scanf("%Lf", & p[i]);
for(R int i = 1; i <= n; i ++) scanf("%Lf", & u[i]);
long double l = 0, r = 1;
for(R int i = 1; i <= 50; i ++) {
long double mid = (l + r) / 2;
if(check(mid)) r = mid;
else l = mid;
}
//printf("%d %d\n", cnt1[n], cnt2[n]);
printf("%.5Lf\n", f[n] + l * a + tl * b);
return 0;
}