problemF.txt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. Problem: F
  2. You are the director of Awesomely Complex Machines (or short: ACM), a company producing
  3. advanced machinery using even more advanced machinery. The old production machinery has broken
  4. down, so you need to buy new production machines for the company. Your goal is to make as much
  5. money as possible during the restructuring period. During this period you will be able to buy and sell
  6. machines and operate them for profit while ACM owns them. Due to space restrictions, ACM can own
  7. at most one machine at a time. During the restructuring period, there will be several machines for sale.
  8. Being an expert in the advanced machines market, you already know the price ​
  9. Pi​​
  10. and the availability
  11. day ​
  12. D​
  13. f
  14. or
  15. each
  16. machines
  17. M
  18. .
  19. Note
  20. that
  21. if
  22. you
  23. do
  24. not
  25. buy
  26. machine
  27. M
  28. on
  29. day
  30. D
  31. then
  32. somebody else
  33. i
  34. i​
  35. i
  36. i
  37. will buy it and it will not be available later. Needless to say, you cannot buy a machine if ACM has less
  38. money than the price of the machine. If you buy a machine ​
  39. M​
  40. D​
  41. i on day ​
  42. i then ACM can operate it
  43. starting on day ​
  44. Di​+ 1. Each day that the machine operates, it produces a profit of ​
  45. Gi​
  46. dollars for the
  47. company.
  48. You may decide to sell a machine to reclaim a part of its purchase price any day after you’ve bought it.
  49. Each machine has a resale price ​
  50. R​
  51. i for which it may be resold to the market. You cannot operate a
  52. machine on the day that you sell it, but you may sell a machine and use the proceeds to buy a new
  53. machine on the same day. Once the restructuring period ends, ACM will sell any machine that it still
  54. owns. Your task is to maximize the amount of money that ACM makes during the restructuring.
  55. Input
  56. The input consists of several test cases. Each test case starts with a line containing three positive
  57. integers ​
  58. N​
  59. ,​
  60. C​
  61. , and ​
  62. D​
  63. .​
  64. N is the number of machines for sale (​
  65. N ≤ 105​
  66. ), ​
  67. C is the number of dollars with
  68. 9​
  69. which the company begins the restructuring (​
  70. C ≤ 10​
  71. ), and ​
  72. D is the number of days that the
  73. restructuring lasts (​
  74. D ≤ 109​
  75. ).
  76. Each of the next ​
  77. N lines describes a single machine for sale. Each line contains four integers ​
  78. D​
  79. P​
  80. R​
  81. i,​​
  82. i,​​
  83. i
  84. and ​
  85. Gi​denoting (respectively) the day on which the machine is for sale, the dollar price for which it
  86. may be bought, the dollar price for which it may be resold and the daily profit generated by operating
  87. the machine. These numbers satisfy the following conditions:
  88. 1 ≤ D​
  89. ≤D
  90. i​
  91. 1 ≤ R​
  92. <
  93. ≤ 109​
  94. i ​ P​
  95. i​
  96. 1 ≤ G​
  97. ≤ 109​
  98. i​
  99. The last test case is followed by a line containing three zeros.
  100. Output
  101. For each test case, display its case number followed by the largest number of dollars that ACM can
  102. have at the end of day ​
  103. D + 1​
  104. . Follow the format of the sample output.
  105. Example Input
  106. 6 10 20
  107. Example Output
  108. Case 1: 44