#P3347. [ZJOI2015] 醉熏熏的幻想乡
[ZJOI2015] 醉熏熏的幻想乡
Description
The tsundere girl Yuuka is a very cute girl. Recently, for some reason, everyone in Gensokyo has been drinking like crazy. Soon the supply of alcohol cannot keep up with demand. To meet everyone’s needs, Yuuka decides to brew alcohol in the forest.
After investigation, Yuuka finds that some places in the forest are very suitable for brewing, while others are very suitable for storage. She calls the places suitable for brewing the brewing sites. Assume there are brewing sites, numbered from to . There are also storage sites, numbered from to . There are channels between some brewing sites and storage sites. If there is a channel between brewing site and storage site , then the alcohol produced at can be transported to .
Brewing at a site consumes Yuuka’s magic. Due to management factors, at brewing site , producing liters of alcohol costs magic. Note that does not have to be a nonnegative integer; it can be any nonnegative real number. Also, at this site at most liters can be produced. Each storage site has a capacity , meaning this storage site can store at most liters of alcohol.
Yuuka plans to store as much alcohol as possible, so she will produce some alcohol at certain brewing sites and transport it through the channels to the storage sites. Of course, Yuuka wants to save her magic, so please help her compute, under the requirement of storing the maximum possible amount, what the minimum magic cost is.
Input Format
The first line contains two positive integers , , the numbers of brewing sites and storage sites. The next lines, on the -th line are three numbers , , , representing the cost coefficients and the production upper bound at brewing site . The next line contains integers, which are the values for each storage site in order. Then there are lines, each containing numbers. On the -th line, the -th number indicates whether there is a channel from brewing site to storage site ( means there is, means there is not).
Output Format
Output the first line as the maximum total liters of alcohol Yuuka can store (note that this is always an integer; just output the integer).
Output the second line as the minimum magic cost. This is always a rational number; after reduction, output it in the form (if it is , output ).
10 10
0 2 3
2 3 2
3 1 3
1 2 1
1 0 1
1 1 0
3 3 0
1 2 2
3 1 1
3 1 0
3 1 2 2 3 1 1 2 2 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
1 0 0 0 1 0 0 0 0 0
1 0 1 0 0 0 0 1 1 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0 1 0
8
42/1
Hint
- For of the testdata: all .
- For another of the testdata: the denominator of the final answer is .
- For of the testdata: , .
- For all testdata, and all are integers. Also, for each , the number of channels with does not exceed .
- Interestingly, for all testdata there exists a positive integer such that there is an optimal solution where the amount transported on every path is a multiple of .
Translated by ChatGPT 5
京公网安备 11011102002149号