QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#9659. 黑客比赛

统计

Fish 刚刚参加了一场编程比赛。在最终排名公布之前,他入侵了数据库,想要修改自己的成绩!

他访问的数据库记录了每道题的提交次数以及每次提交的结果(是否通过,即 AC)。他很快发现,虽然每次提交的时间是乱序存储的,但他无法修改这些时间(也不能修改每道题的提交次数)。他可以修改的是每次提交对应的题目编号和结果。为了不让结果显得太奇怪,最终他不能在某道题获得 AC 后,再对该题进行任何提交。

你一定知道,参赛者的排名规则是:先按解题数量从多到少排序,解题数量相同时,按罚时从少到多排序。解题的罚时是每道已解决题目所耗费时间之和。对于一道已解决的题目,其耗费时间为该题第一次 AC 提交的时间,加上该题在第一次 AC 之前所有未通过提交次数乘以 20。

请帮助 Fish 找到他能获得的最好结果(即最小罚时)。

输入格式

第一行包含一个整数 $T$,表示测试用例的数量。

对于每个测试用例: 第一行包含两个整数 $N$ 和 $M$,分别表示提交次数和题目数量。 第二行包含 $N$ 个整数 $t_i$,表示每次提交的时间。 第三行包含 $M$ 个整数 $c_i$,表示每道题的提交次数。

输出格式

对于每个测试用例,输出 Case x: y,其中 $x$ 表示从 1 开始的用例编号,$y$ 表示他能获得的最好结果(最小罚时)。

样例

输入 1

2
4 2
10 20 30 40
2 2
4 3
10 20 30 40
1 1 2

输出 1

Case 1: 100
Case 2: 90

数据范围

$1 \le T \le 100$ $1 \le N \le 10^5$ $1 \le M \le \min(N, 13)$ $1 \le t_i \le 300$ $\sum c_i = N$ 对于 90% 的测试用例:$N \le 100$

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.