QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 4096 MB Total points: 100

#7288. 果冻口味

Statistics

Amy 是果冻的忠实粉丝,她想买一些果冻作为甜点。共有 $n$ 种口味的果冻,编号为 $0$ 到 $n-1$。A 商店出售口味 $i$ 的果冻,单价为 $a[i]$ 美元;B 商店出售口味 $i$ 的果冻,单价为 $b[i]$ 美元。Amy 在 A 商店最多可以花费 $x$ 美元,在 B 商店最多可以花费 $y$ 美元。

请帮助 Amy 计算她最多可以购买多少种不同口味的果冻。

实现细节

你需要实现以下函数:

int find_maximum_unique(int x, int y, int[] a, int[] b)
  • $x$:可以在 A 商店花费的金额。
  • $y$:可以在 B 商店花费的金额。
  • $a$:长度为 $n$ 的数组,包含每种果冻在 A 商店的价格。
  • $b$:长度为 $n$ 的数组,包含每种果冻在 B 商店的价格。
  • 该函数将被调用恰好一次。
  • 该函数应返回 Amy 可以购买的最多不同口味果冻的数量。

样例

样例 1

考虑以下调用:

find_maximum_unique(2, 3, [2, 1, 4], [2, 3, 2])

这意味着 Amy 在 A 商店最多可以花费 $2$ 美元,在 B 商店最多可以花费 $3$ 美元,价格如下: 果冻 $0$ 在 A 商店和 B 商店的价格均为 $2$ 美元。 果冻 $1$ 在 A 商店的价格为 $1$ 美元,在 B 商店的价格为 $3$ 美元。 * 果冻 $2$ 在 A 商店的价格为 $4$ 美元,在 B 商店的价格为 $2$ 美元。

Amy 最多可以购买 $2$ 种不同口味的果冻。这可以通过从 A 商店购买果冻 $0$ 和从 B 商店购买果冻 $2$ 来实现,每个花费 $2$ 美元。

因此,该函数应返回 $2$。

样例 2

考虑以下调用:

find_maximum_unique(6, 12, [5, 1, 5, 6, 3], [3, 5, 4, 6, 7])

在这种情况下,Amy 最多可以购买 $4$ 种不同口味的果冻。这可以通过从 A 商店购买果冻 $1$ 和 $2$(花费 $1 + 5 = 6$ 美元),以及从 B 商店购买果冻 $0$ 和 $4$(花费 $3 + 7 = 10$ 美元)来实现。

因此,该函数应返回 $4$。

数据范围

  • $1 \le n \le 2000$
  • $0 \le x, y \le 10\,000$
  • $0 \le a[i], b[i] \le 10\,000$ (对于所有 $0 \le i \le n - 1$)

子任务

  1. (11 分) $x, y \le 500, n \le 12$
  2. (24 分) $x, y \le 500, n \le 200$
  3. (9 分) $y = 0$
  4. (10 分) $b[i] = b[j]$ (对于所有 $0 \le i, j \le n - 1$)
  5. (14 分) $a[i] = b[i]$ (对于所有 $0 \le i \le n - 1$)
  6. (32 分) 无附加限制。

样例评测程序

样例评测程序按以下格式读取输入:

  • 第 1 行:$n \ x \ y$
  • 第 $2 + i$ 行($0 \le i \le n - 1$):$a[i] \ b[i]$

样例评测程序按以下格式输出结果:

  • 第 1 行:find_maximum_unique 的返回值。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.