P6849 [THUWC 2017] The Divine Power of Scallions

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.

Description

Now student Xiaocong has $N$ scallions and $M$ drawers. Placing the $i$-th scallion into the $j$-th drawer will generate divine power $w_{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 $i$-th scallion is $a_i$, and the capacity of the $j$-th drawer is $b_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, M$, representing the number of scallions and the number of drawers. The next line contains $N$ integers, representing the volume of each scallion. The next line contains $M$ integers, representing the capacity of each drawer. Then follow $N$ lines, each containing $M$ integers. The $j$-th number on the $i$-th line represents the divine power generated by placing the $i$-th scallion into the $j$-th drawer.

Output Format

The output files are `drawer1.out ~ drawer10.out`, corresponding to the respective input files. For each input dataset, output $N$ lines, each containing one integer. The $i$-th number indicates which drawer the $i$-th scallion is placed into. If the $i$-th scallion is not placed into any drawer, output $0$.

Explanation/Hint

#### Sample Explanation The sample is just one valid arrangement, and the total divine power obtained is $2+3=5$. #### Scoring **This problem uses a Special Judge.** For each test point, we have $10$ parameters $a_1, a_2, \cdots, a_{10}$. If the divine power $v$ produced by your output satisfies $v \ge a_i$, then we guarantee that for this test point you will get at least $i$ 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: ```plain ./scorer ``` Or in the command prompt (Windows), enter the following command: ```plain scorer ``` to evaluate your output. Here, `` is the input file name, and `` is the output file name. Translated by ChatGPT 5