{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n The Mid-Autumn Festival, also known as the Moon Festival or Zhongqiu Festival is a popular harvest festival celebrated by Chinese people, dating back over 3,000 years to moon worship in China\u0027s Shang Dynasty. The Zhongqiu Festival is held on the 15th day of the eighth month in the Chinese calendar, which is in September or early October in the Gregorian calendar. It is a date that parallels the autumnal equinox of the solar calendar, when the moon is at its fullest and roundest. \n \u003cbr\u003e \n \u003ccenter\u003e \n \u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/52824cfa4ec02012d617b97fad81eea1?v\u003d1609344146\"\u003e \n \u003c/center\u003e \n \u003cbr\u003eThe traditional food of this festival is the mooncake. Chinese family members and friends will gather to admire the bright mid-autumn harvest moon, and eat mooncakes under the moon together. In Chinese, “round”(圆) also means something like “faultless” or “reuion”, so the roundest moon, and the round mooncakes make the Zhongqiu Festival a day of family reunion. \n \u003cbr\u003e \n \u003cbr\u003eAlice has opened up a 24-hour mooncake shop. She always gets a lot of orders. Only when the time is K o’clock sharp( K \u003d 0,1,2 …. 23) she can make mooncakes, and We assume that making cakes takes no time. Due to the fluctuation of the price of the ingredients, the cost of a mooncake varies from hour to hour. She can make mooncakes when the order comes,or she can make mooncakes earlier than needed and store them in a fridge. The cost to store a mooncake for an hour is S and the storage life of a mooncake is T hours. She now asks you for help to work out a plan to minimize the cost to fulfill the orders. \u003cbr\u003e\n有一个蛋糕店,在某个时刻会有一些订单,你可以选择在订单之前的任意时刻做好。在每个时刻做一个蛋糕都有不同的花费,并且蛋糕有固定的保存开销和保质期,问什么时候做蛋糕使得开销最小。\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains no more than 10 test cases. \n\u003cbr\u003eFor each test case: \n\u003cbr\u003eThe first line includes two integers N and M. N is the total number of orders. M is the number of hours the shop opens. \n\u003cbr\u003eThe next N lines describe all the orders. Each line is in the following format: \n\u003cbr\u003e \n\u003cbr\u003emonth date year H R \n\u003cbr\u003e \n\u003cbr\u003eIt means that on a certain date, a customer orders R mooncakes at H o’clock. “month” is in the format of abbreviation, so it could be \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\" or \"Dec\". H and R are all integers. \n\u003cbr\u003eAll the orders are sorted by the time in increasing order. \n\u003cbr\u003eThe next line contains T and S meaning that the storage life of a mooncake is T hours and the cost to store a mooncake for an hour is S. \n\u003cbr\u003eFinally, M lines follow. Among those M lines, the i\u003csup\u003eth\u003c/sup\u003e line( i starts from 1) contains a integer indicating the cost to make a mooncake during the i\u003csup\u003eth\u003c/sup\u003e hour . The cost is no more than 10000. Jan 1st 2000 0 o\u0027clock belongs to the 1\u003csup\u003est\u003c/sup\u003e hour, Jan 1st 2000 1 o\u0027clock belongs to the 2\u003csup\u003end\u003c/sup\u003e hour, …… and so on. \n\u003cbr\u003e \n\u003cbr\u003e(0\u0026lt;N \u0026lt;\u003d 2500; 0 \u0026lt; M,T \u0026lt;\u003d100000; 0\u0026lt;\u003dS \u0026lt;\u003d 200; R\u0026lt;\u003d10000 ; 0\u0026lt;\u003dH\u0026lt;24) \n\u003cbr\u003e \n\u003cbr\u003eThe input ends with N \u003d 0 and M \u003d 0.\n第一行n,m;随后n行代表在某年某月某日有人预定x个月饼,随后一行t,s,月饼最长保存时间和每个月饼保存一小时的费用。随后m行,在0-m的时间制作月饼需要的费用。求完成订单需要的最小成本。"}},{"title":"Output","value":{"format":"HTML","content":"You should output one line for each test case: the minimum cost. \n\u003cbr\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e1 10\nJan 1 2000 9 10\n5 2\n20 \n20 \n20 \n10 \n10\n8\n7 \n9 \n5 \n10\n0 0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e70\n\n \n \u003ci style\u003d\"font-size:1px\"\u003e \u003c/i\u003e\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cpre\u003e\n“Jan 1 2000 9 10” means in Jan 1st 2000 at 9 o\u0027clock , there\u0027s a consumer ordering 10 mooncakes. \nMaybe you should use 64-bit signed integers. The answer will fit into a 64-bit signed integer.\n\n \n \u003c/pre\u003e"}}]}