#P3652. csh和zzy的战争
csh和zzy的战争
Description
There are cargo origins, each with some goods to be shipped. Ahead are transfer islands, and your goal is to deliver all goods to the front-line military base. The shipping rules are as follows:
- Each island can accept goods only from specific cargo origins, and only certain designated islands can ship to the military base.
- There are sea lanes between islands. Each sea lane has a weight representing the cost to open that lane. For any two islands, the cost to enable cargo shipping between them equals the length of the shortest path between them (sum of edge weights).
- At any time, the number of goods simultaneously stored on an island must not exceed its storage limit .
- Each island can ship out at most goods in total, and to each destination it can deliver at most once.
- There are special cargo origins (not included in ) that carry some private goods of csh and zzy. These goods will be unconditionally accepted and forwarded by any island, i.e., they are not subject to rules 3 and 4.
- The development cost of the entire route equals , the maximum among all pairs of islands for which shipping is enabled.
Find the minimal such that all goods can be delivered to the military base in accordance with the above rules.
Input Format
- The first line contains , , , , denoting the number of cargo origins, the number of transfer islands, the number of special cargo origins, and the number of sea lanes, respectively. The cargo origins and special cargo origins are indexed in order.
- The second line contains integers , the amount of goods pending shipment at each cargo origin.
- The third line contains integers, the storage limits of the islands.
- The fourth line contains integers, the outbound shipping limits of the islands.
- The next lines describe the connections from origins to islands. Each line starts with an integer , the number of cargo origins (including special ones) connected to this island, followed by integers listing the indices of those origins, and finally one integer indicating whether this island is connected to the military base (1 for yes, 0 for no).
- The next lines each contain three integers , , , indicating there is a sea lane between islands and with weight .
Output Format
Output a single integer , the minimal development cost that allows all goods to be delivered to the military base while satisfying the rules.
2 3 1 1
2 2 2
4 4 4
2 1 1
1 1 1
1 2 1
1 3 1
2 3 4
4
Hint
Constraints: For of the testdata, , .
Several tips: https://www.luogu.com.cn/discuss/47710.
Translated by ChatGPT 5
京公网安备 11011102002149号