题解:先写了一发双指针,悲惨的fst了。 最气的是还找不出来哪儿写错了。 换成二分法写,错了好几发。
题中说了第二种方式的方案ci,di都以递增的形式给出来,那么我们直接遍历,然后二分出满足条件的最大ci就行了。
代码如下:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 2e5+10;
#define LL long long
LL a[maxn],b[maxn],c[maxn],d[maxn];
int main()
{
LL n,m,k,x,s;
while(scanf("%lld%lld%lld",&n,&m,&k)!=EOF)
{
scanf("%lld%lld",&x,&s);
for(int i=0;i<m;++i)
scanf("%lld",&a[i]);
for(int i=0;i<m;++i)
scanf("%lld",&b[i]);
for(int i=1;i<=k;++i)
scanf("%lld",&c[i]);
for(int i=1;i<=k;++i)
scanf("%lld",&d[i]);
LL ans =(n - c[upper_bound(d+1,d+k+1,s)-d-1]) * x; //数组下标从1开始,避免数组下标可能为-1
for(int i=0;i<m;++i)
{
if(b[i]>s)
continue;
ans = min(ans, (n - c[upper_bound(d+1,d+k+1,s-b[i])-d-1]) * a[i]);
}
printf("%lld\n",ans);
}
return 0;
}