#P6849. [THUWC 2017] 大葱的神力
[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 scallions and drawers. Placing the -th scallion into the -th drawer will generate divine power . 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 -th scallion is , and the capacity of the -th drawer is . 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 , representing the number of scallions and the number of drawers.
The next line contains integers, representing the volume of each scallion.
The next line contains integers, representing the capacity of each drawer.
Then follow lines, each containing integers. The -th number on the -th line represents the divine power generated by placing the -th scallion into the -th drawer.
Output Format
The output files are drawer1.out ~ drawer10.out, corresponding to the respective input files.
For each input dataset, output lines, each containing one integer. The -th number indicates which drawer the -th scallion is placed into. If the -th scallion is not placed into any drawer, output .
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 .
Scoring
This problem uses a Special Judge. For each test point, we have parameters . If the divine power produced by your output satisfies , then we guarantee that for this test point you will get at least 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