AT_abc476_d.Automat
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In the Kingdom of AtCoder, two kinds of bills are in circulation: 1-dollar bills and K-dollar bills.
At Company J's fully automated cafeteria in the kingdom, desserts and drinks are sold as products.
The company's fully automated cafeteria has a dessert vending machine that sells N desserts, and a drink vending machine that sells M drinks. The desserts are numbered 1 through N, and the drinks are numbered 1 through M.
Dessert i costs Ai dollars, and drink j costs Bj dollars.
As payment, the dessert vending machine accepts both 1-dollar bills and K-dollar bills, but the drink vending machine accepts only K-dollar bills. Both vending machines give change using only 1-dollar bills. You cannot buy two or more of the same product.
Takahashi came to Company J's fully automated cafeteria with X 1-dollar bills and Y K-dollar bills.
Among the combinations of products that he can buy with the bills he has, find the maximum number of products he can purchase.
在 AtCoder 王国,市面上流通两种纸币:面值为 1 美元的纸币和面值为 K 美元的纸币。
王国中公司 J 的全自动自助餐厅出售甜点和饮品两类商品。
该公司全自动自助餐厅配备一台甜点自动售货机(共出售 N 种甜点)和一台饮品自动售货机(共出售 M 种饮品)。甜点编号为 1 至 N,饮品编号为 1 至 M。
甜点 i 的价格为 Ai 美元,饮品 j 的价格为 Bj 美元。
支付时,甜点自动售货机可接受 1 美元纸币和 K 美元纸币;而饮品自动售货机仅接受 K 美元纸币。两台售货机均只使用 1 美元纸币找零。每种商品最多只能购买一件。
高桥来到公司 J 的全自动自助餐厅,身上带有 X 张 1 美元纸币和 Y 张 K 美元纸币。
在所有他能负担得起的商品组合中,求他最多能购买的商品总数。
输入格式
The input is given from Standard Input in the following format:
N M K
X Y
A1 … AN
B1 … BM
输入从标准输入中按以下格式给出:
N M K
X Y
A1 … AN
B1 … BM
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
2 3 10 50 6 22 30 20 12 24
输出#1
4
输入#2
1 7 67 677677677766666 0 777666777 20 12 24 67 67 67 67
输出#2
1
输入#3
20 20 30 605776135 133105105 97363214 218434035 697895427 109255624 299037330 227873982 195540071 411713803 828357845 244535208 138059186 639510883 39844882 707397687 371274487 696536603 351588202 319490007 47121612 87169661 32256972 567982330 554885983 299718223 443859449 687952877 264684780 666659381 576335424 941894234 406248934 321334900 423472560 863738035 213143887 384834384 468161291 673106162 164648316 15903323
输出#3
22
说明/提示
Sample 1 Explanation:
By shopping as follows, Takahashi can buy four products.
- Pay two 10-dollar bills to buy drink 1. No change.
- Pay two 10-dollar bills to buy drink 2. The change is eight 1-dollar bills.
- Pay two 10-dollar bills and ten 1-dollar bills to buy dessert 2. No change.
- Pay twenty-two 1-dollar bills to buy dessert 1. No change.
He cannot buy more than four products, so the answer is 4.
Sample 2 Explanation:
By shopping as follows, Takahashi can buy one product.
- Pay 600000777666777 1-dollar bills to buy dessert 1. The change is 600000000000000 1-dollar bills.
He cannot buy more than one product, so the answer is 1.
Constraints
- 1≤N≤2×105
- 1≤M≤2×105
- 2≤K≤109
- 0≤X≤1015
- 0≤Y≤109
- 1≤Ai≤109 (1≤i≤N)
- 1≤Bj≤109 (1≤j≤M)
- All input values are integers.
样例 1 解释:
通过如下购物方式,高桥可以购买四件商品。
- 支付两张 10 美元纸币购买饮料 1。无需找零。
- 支付两张 10 美元纸币购买饮料 2。找回八张 1 美元纸币。
- 支付两张 10 美元纸币和十张 1 美元纸币购买甜点 2。无需找零。
- 支付二十二张 1 美元纸币购买甜点 1。无需找零。
他无法购买超过四件商品,因此答案为 4。
样例 2 解释:
通过如下购物方式,高桥可以购买一件商品。
- 支付 600000777666777 张 1 美元纸币购买甜点 1。找回 600000000000000 张 1 美元纸币。
他无法购买超过一件商品,因此答案为 1。
限制条件
- 1≤N≤2×105
- 1≤M≤2×105
- 2≤K≤109
- 0≤X≤1015
- 0≤Y≤109
- 1≤Ai≤109(1≤i≤N)
- 1≤Bj≤109(1≤j≤M)
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?