#P2317. [HNOI2005] 星际贸易

    ID: 1286 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp2005各省省选湖南最短路

[HNOI2005] 星际贸易

Description

Coke\text{Coke} is a shrewd small merchant. This time he wants to boldly engage in interstellar trade. He chooses a trade route specified by the Galactic Trade and Traffic Authority, starting from Earth and passing in order through Star1,Star2,,StarNStar_1, Star_2, \cdots, Star_N. The route ends at StarNStar_N (where Coke\text{Coke} will go sightseeing).

The planets in the galaxy operate under a planned economy. To sell goods on a planet, you must have that planet’s license. The licenses Coke\text{Coke} holds allow him to sell exactly the quota amount AiA_i tons of goods on StariStar_i with 1Ai1001 \le A_i \le 100 (neither more nor less; of course, he may choose not to sell anything on StariStar_i). After selling, he can obtain income BiB_i with 0Bi500000 \le B_i \le 50000. Because his private spaceship has limited payload, this shrewd merchant must carefully plan which planets to sell on.

The spaceship uses an antimatter propulsion system and requires antimatter fuel. Antimatter fuel is not used to maintain ordinary flight (there is no drag in space); it is used for acceleration when leaving a planet and deceleration when arriving at a planet. Each acceleration and each deceleration consumes one unit of antimatter fuel.

Furthermore, for such a long trip, the spaceship must stop en route at some planets to replenish antimatter fuel and to perform regular maintenance (maintenance can only be done on planets). Due to different levels of technological development, the price of antimatter fuel and the maintenance cost vary from planet to planet.

In addition, the Galactic Trade and Traffic Authority is hosting a small-merchant trade competition, with generous rewards for the merchant with the highest trade revenue (i.e., total trade income). Therefore, Coke\text{Coke} decides to spare no expense to maximize his trade revenue. Of course, while maximizing trade revenue, as a merchant he still hopes the net profit is as large as possible (net profit = trade revenue − fuel cost − maintenance cost).

Assume that when departing from Earth, the spaceship has just been maintained and its fuel tank is full. Whenever the spaceship stops at a planet to sell goods or to refuel, or when it arrives at the terminal for sightseeing, it will undergo maintenance there once. Coke\text{Coke} wants you to devise a plan that meets his requirements.

Input Format

The first line contains four positive integers N,M,R,L0N, M, R, L_0.

  • NN (1N20001 \le N \le 2000) is the number of planets on the route this time.
  • MM (1M20001 \le M \le 2000) is the spaceship’s maximum cargo capacity.
  • RR (0R100000000 \le R \le 10000000) is the maximum amount of fuel the spaceship can carry.
  • L0L_0 (1L01001 \le L_0 \le 100) is the maximum distance the spaceship can fly without maintenance.

The next NN lines (lines 22 to N+1N+1) each describe a planet. Line i+1i+1 contains five non-negative integers Ai,Bi,Li,Pi,FiA_i, B_i, L_i, P_i, F_i:

  • AiA_i (1Ai1001 \le A_i \le 100) is the sale quota (tons) on StariStar_i.
  • BiB_i (0Bi500000 \le B_i \le 50000) is the income from selling on StariStar_i.
  • LiL_i (1Li1001 \le L_i \le 100) is the distance from Earth to StariStar_i along the route EarthStar1Star2StariEarth \to Star_1 \to Star_2 \to \cdots \to Star_i.
  • PiP_i (0Pi10000 \le P_i \le 1000) is the price per unit of antimatter on StariStar_i. If Pi=0P_i = 0, this planet does not yet have antimatter manufacturing technology.
  • FiF_i (0Fi100000 \le F_i \le 10000) is the maintenance cost on StariStar_i.

Assume the input satisfies: for i<ji < j, it always holds that Li<LjL_i < L_j, and there is exactly one way to achieve the maximum trade revenue.

Output Format

If such a plan exists, output two integers XX and YY separated by a space. XX is the maximum trade revenue, and YY is the net profit. If the trip cannot be completed, output “Poor Coke!”.

6 3 10 4
1 2 1 1 1
1 2 2 2 1
1 2 3 9 1
1 1 4 0 1
1 1 5 0 1
1 1 6 1 1

6 2
6 3 2 4
1 2 1 1 1
1 2 2 2 1
1 2 3 0 1
1 1 4 0 1
1 1 5 0 1
1 1 6 1 1

Poor Coke!

Hint

Translated by ChatGPT 5