本以为是个水题,也WA了N次
然后看别的代码
感觉题意理解错了一个点,倒是WA
别的还暴露出来:
lower_bound理解出现偏差,输出调试才看出来
然后就是long long和int转换
以后需要long long的就全盘long long吧,省得出现意外
——
下面说下题意
第一行输入
N M K
表示你要造N个东西 有A类魔法 M个 B类魔法 K个
第二行输入
X S
表示每个东西的价格是 X 同时有S点魔法值
第三行输入 A1…AM
第四行输入 B1…BM
A类魔法是可以把X变成Ai,同时消耗B类魔法
题目说了Ai < X, 所以不会出现越来越贵的情况
第五行输入 C1…CK
第六行输入 D1…DK
B类魔法是可以把东西从N个减少Ci个,同时消耗Di个魔法值
题目保证Ci不减 Di不减
然后每个魔法最多用一次,所以ANS最大就是N*X
——
算法
这个明显二分,从Ci不减Di不减就能看出来,比赛的时候愣是没想到,以为更水,不提不提
就是枚举每一次用A魔法,然后二分B魔法,就可以找到最大了的
#define LOG(x) cout << #x << " = " << (x) << endl
#define PRINTLN(x) cout << (x) << endl
#define MEM(x, y) memset((x), (y), sizeof((x)))
#include <bits/stdc++.h>
using namespace std;
const double PI = 2*acos(0);
typedef long long ll;
typedef complex<double> Complex;
int nextInt()
{
int x;
scanf("%d", &x);
return x;
}
ll nextLL()
{
ll x;
scanf("%lld", &x);
return x;
}
//TEMPLATE
//MAIN
ll n;
int m, k;
const int MAXM = 2E5 + 9;
const int MAXK = 2E5 + 9;
const int INF = INT_MAX;
ll a[MAXM], b[MAXM], c[MAXK], d[MAXK];
void solve()
{
ll x = nextLL(), s = nextLL();
a[0] = x;
b[0] = 0;
c[0] = 0;
d[0] = 0;
for (int i = 1; i <= m; i++) a[i] = nextLL();
for (int i = 1; i <= m; i++) b[i] = nextLL();
for (int i = 1; i <= k; i++) c[i] = nextLL();
for (int i = 1; i <= k; i++) d[i] = nextLL();
ll ans = n * x;
for (int i = 0; i <= m; i++) {
if (b[i] > s) continue;
int j = upper_bound(d, d + k + 1, s - b[i]) - d;
ans = min(ans, (n - c[j - 1]) * a[i]);
}
cout << ans << endl;
}
int main()
{
//freopen("in.txt", "r", stdin);
while (scanf("%lld%d%d", &n, &m, &k) != EOF) {
solve();
}
}