{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cpre\u003e\ntag:需要学过动态规划\nby wzc\nwzc最近在一家糕点店学习制作糕点,现在他需要利用手上的一些材料来制作糕点销售。\n他一开始拥有着n份面粉,有m种糕点可以制作。\n每种糕点的制作出了面粉之外还需要对应的馅料(每种糕点与其馅料是一一对应的)。\n对于第i种糕点,目前剩余的对应馅料还有ai份,制作一份糕点需要bi份馅料和ci份面粉,可以销售出di元钱。\n当然他也可以选择不加馅料直接卖,利用c0的面粉制作出一份糕点,可以售出d0元钱。\n\n现在他想知道他可以利用手上的材料最多获得多少钱。\n\u003cpre\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cpre\u003e\n第一行有四个整数n,m,c0,d0(1 \u003c \u003d n \u003c \u003d1000,1 \u003c \u003d m \u003c \u003d 10,1 \u003c \u003d c0,d0\u003c \u003d 100)\n接下来m行,第i行包括四个整数ai,bi,ci,di,分别是第i种糕点对应的a,b,c,d值。\n(1 \u003c \u003d ai,bi,ci,di\u003c \u003d100)\n\u003cpre\u003e"}},{"title":"Output","value":{"format":"HTML","content":"在一行当中输出可以获得的最大收益。"}},{"title":"Examples","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e \n \u003cdiv class\u003d\"input\"\u003e \n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e \n \u003cpre\u003e10 2 2 1\u003cbr\u003e5 2 2 10\u003cbr\u003e8 2 1 1\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e \n \u003cdiv class\u003d\"output\"\u003e \n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e \n \u003cpre\u003e25\u003c/pre\u003e\n \u003c/div\u003e \n \u003cdiv class\u003d\"input\"\u003e \n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e \n \u003cpre\u003e10 1 5 11\u003cbr\u003e3 1 3 8\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e \n \u003cdiv class\u003d\"output\"\u003e \n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e \n \u003cpre\u003e24\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cpre\u003e\n对于第一组样例,我们可以选择制作两份第一种糕点和四份第二种糕点,再制作一份无馅料的糕点。\n对于第二组样例,我们可以选择制作三份第一种糕点。\n\u003cpre\u003e"}}]}