QOJ.ac

QOJ

時間限制: 15 s 記憶體限制: 256 MB 總分: 100

#11333. 洗涤

统计

熊猫先生准备去洗衣服了!他带了 $L$ 份相同的衣物去当地的洗衣店,洗衣店里有 $N$ 台洗衣机和 $M$ 台烘干机。 第 $i$ 台洗衣机洗完一份衣物需要 $W_i$ 分钟,第 $i$ 台烘干机烘干一份衣物需要 $D_i$ 分钟。 在任何时刻,每台机器最多只能处理一份衣物。 正如你所预料的,熊猫先生想要洗完并烘干他所有的 $L$ 份衣物。每一份衣物都需要按顺序经过以下步骤:

  1. 在熊猫先生到达洗衣店后的某个非负时间点,他将衣物放入一台空闲的洗衣机 $i$ 中。
  2. $W_i$ 分钟后,他将衣物从洗衣机中取出,放入一个临时存放篮中(篮子空间无限)。
  3. 在之后的某个非负时间点,他将衣物放入一台空闲的烘干机 $j$ 中。
  4. $D_j$ 分钟后,他将衣物从烘干机中取出。

熊猫先生可以瞬间完成衣物的放入或取出操作。请帮助熊猫先生计算,从他到达洗衣店开始,最少需要多少分钟才能洗完并烘干所有 $L$ 份衣物。

输入格式

输入的第一行包含一个整数 $T$,表示测试用例的数量。 接下来是 $T$ 个测试用例。每个测试用例包含三行。第一行包含三个整数 $L$、$N$ 和 $M$。 第二行包含 $N$ 个整数 $W_1, W_2, \dots, W_N$,表示每台洗衣机的洗涤时间。 第三行包含 $M$ 个整数 $D_1, D_2, \dots, D_M$,表示每台烘干机的烘干时间。

输出格式

对于每个测试用例,输出一行 “Case #x: y”,其中 $x$ 是测试用例编号(从 1 开始),$y$ 是熊猫先生完成所有洗衣任务所需的最短时间。

数据范围

  • $1 \le T \le 100$
  • $1 \le L \le 10^6$
  • $1 \le N, M \le 10^5$
  • $1 \le W_i, D_i \le 10^9$

样例

输入 1

2
1 1 1
1200
34
2 3 2
100 10 1
10 10

输出 1

Case #1: 1234
Case #2: 12

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.