#P6849. [THUWC 2017] 大葱的神力

    ID: 7553 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>动态规划 DP搜索2017提交答案Special Judge剪枝模拟退火背包 DP费用流随机化THUWC

[THUWC 2017] 大葱的神力

Background

This is an output-only problem.

Scallions have been a delicacy in China since ancient times. For example, the traditional dish Peking Duck uses duck to bring out the fragrance of scallions, which people praise highly. There is also a folk saying: “One scallion a day, no more being a single dog.”

However, for scallions to unleash their unique divine power, certain conditions must be met.

Problem Description

Now student Xiaocong has NN scallions and MM drawers. Placing the ii-th scallion into the jj-th drawer will generate divine power wi,jw_{i,j}. Naturally, Xiaocong wants to obtain as much divine power as possible, but drawers have capacity limits, and scallions have their own volumes. The volume of the ii-th scallion is aia_i, and the capacity of the jj-th drawer is bjb_j. The total volume of scallions placed in a drawer cannot exceed that drawer’s capacity, and a scallion cannot be split across two drawers.

Xiaocong now wants to know: under these conditions, what is the maximum total divine power these scallions can generate?

Input Format

This is an output-only problem. The input files are drawer1.in ~ drawer10.in. See the attachment for details.

The first line contains two integers N,MN, M, representing the number of scallions and the number of drawers.

The next line contains NN integers, representing the volume of each scallion.

The next line contains MM integers, representing the capacity of each drawer.

Then follow NN lines, each containing MM integers. The jj-th number on the ii-th line represents the divine power generated by placing the ii-th scallion into the jj-th drawer.

Output Format

The output files are drawer1.out ~ drawer10.out, corresponding to the respective input files.

For each input dataset, output NN lines, each containing one integer. The ii-th number indicates which drawer the ii-th scallion is placed into. If the ii-th scallion is not placed into any drawer, output 00.

3 4
1 1 2
2 1 2 3
1 2 1 1
2 1 2 1
3 1 0 1
2
0
1

Hint

Sample Explanation

The sample is just one valid arrangement, and the total divine power obtained is 2+3=52+3=5.

Scoring

This problem uses a Special Judge. For each test point, we have 1010 parameters a1,a2,,a10a_1, a_2, \cdots, a_{10}. If the divine power vv produced by your output satisfies vaiv \ge a_i, then we guarantee that for this test point you will get at least ii points.

How to Test Your Output

In the attachments, we provide scorer.cpp. Please compile it yourself to test your output. This program will be used to evaluate how much divine power your output can produce.

If the compiled file name is scorer, then in the terminal (Linux), enter the following command:

./scorer <input_name> <output_name>

Or in the command prompt (Windows), enter the following command:

scorer <input_name> <output_name>

to evaluate your output. Here, <input_name> is the input file name, and <output_name> is the output file name.

Translated by ChatGPT 5