AT_abc476_d.Automat

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In the Kingdom of AtCoder, two kinds of bills are in circulation: 11-dollar bills and KK-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 NN desserts, and a drink vending machine that sells MM drinks. The desserts are numbered 11 through NN, and the drinks are numbered 11 through MM.

Dessert ii costs AiA_i dollars, and drink jj costs BjB_j dollars.

As payment, the dessert vending machine accepts both 11-dollar bills and KK-dollar bills, but the drink vending machine accepts only KK-dollar bills. Both vending machines give change using only 11-dollar bills. You cannot buy two or more of the same product.

Takahashi came to Company J's fully automated cafeteria with XX 11-dollar bills and YY KK-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 王国,市面上流通两种纸币:面值为 11 美元的纸币和面值为 KK 美元的纸币。

王国中公司 J 的全自动自助餐厅出售甜点和饮品两类商品。

该公司全自动自助餐厅配备一台甜点自动售货机(共出售 NN 种甜点)和一台饮品自动售货机(共出售 MM 种饮品)。甜点编号为 11 至 NN,饮品编号为 11 至 MM。

甜点 ii 的价格为 AiA_i 美元,饮品 jj 的价格为 BjB_j 美元。

支付时,甜点自动售货机可接受 11 美元纸币和 KK 美元纸币;而饮品自动售货机仅接受 KK 美元纸币。两台售货机均只使用 11 美元纸币找零。每种商品最多只能购买一件。

高桥来到公司 J 的全自动自助餐厅,身上带有 XX 张 11 美元纸币和 YY 张 KK 美元纸币。

在所有他能负担得起的商品组合中,求他最多能购买的商品总数。

输入格式

The input is given from Standard Input in the following format:

NN MM KK
XX YY
A1A_1 …\dots ANA_N
B1B_1 …\dots BMB_M

输入从标准输入中按以下格式给出:

NN MM KK
XX YY
A1A_1 …\dots ANA_N
B1B_1 …\dots BMB_M

输出格式

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 1010-dollar bills to buy drink 11. No change.
  • Pay two 1010-dollar bills to buy drink 22. The change is eight 11-dollar bills.
  • Pay two 1010-dollar bills and ten 11-dollar bills to buy dessert 22. No change.
  • Pay twenty-two 11-dollar bills to buy dessert 11. No change.

He cannot buy more than four products, so the answer is 44.

Sample 2 Explanation:
By shopping as follows, Takahashi can buy one product.

  • Pay 600000777666777600000777666777 11-dollar bills to buy dessert 11. The change is 600000000000000600000000000000 11-dollar bills.

He cannot buy more than one product, so the answer is 11.

Constraints

  • 1≤N≤2×1051 \leq N \leq 2 \times 10^5
  • 1≤M≤2×1051 \leq M \leq 2 \times 10^5
  • 2≤K≤1092 \leq K \leq 10^9
  • 0≤X≤10150 \leq X \leq 10^{15}
  • 0≤Y≤1090 \leq Y \leq 10^9
  • 1≤Ai≤1091 \leq A_i \leq 10^9 (1≤i≤N1 \leq i \leq N)
  • 1≤Bj≤1091 \leq B_j \leq 10^9 (1≤j≤M1 \leq j \leq M)
  • All input values are integers.

样例 1 解释:
通过如下购物方式,高桥可以购买四件商品。

  • 支付两张 1010 美元纸币购买饮料 11。无需找零。
  • 支付两张 1010 美元纸币购买饮料 22。找回八张 11 美元纸币。
  • 支付两张 1010 美元纸币和十张 11 美元纸币购买甜点 22。无需找零。
  • 支付二十二张 11 美元纸币购买甜点 11。无需找零。

他无法购买超过四件商品,因此答案为 44。

样例 2 解释:
通过如下购物方式,高桥可以购买一件商品。

  • 支付 600000777666777600000777666777 张 11 美元纸币购买甜点 11。找回 600000000000000600000000000000 张 11 美元纸币。

他无法购买超过一件商品,因此答案为 11。

限制条件

  • 1≤N≤2×1051 \leq N \leq 2 \times 10^5
  • 1≤M≤2×1051 \leq M \leq 2 \times 10^5
  • 2≤K≤1092 \leq K \leq 10^9
  • 0≤X≤10150 \leq X \leq 10^{15}
  • 0≤Y≤1090 \leq Y \leq 10^9
  • 1≤Ai≤1091 \leq A_i \leq 10^9(1≤i≤N1 \leq i \leq N)
  • 1≤Bj≤1091 \leq B_j \leq 10^9(1≤j≤M1 \leq j \leq M)
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页