{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cp\u003eThere are \u003cvar\u003eN\u003c/var\u003e one-off jobs available. If you take the \u003cvar\u003ei\u003c/var\u003e-th job and complete it, you will earn the reward of \u003cvar\u003eB_i\u003c/var\u003e after \u003cvar\u003eA_i\u003c/var\u003e days from the day you do it.\u003c/p\u003e \n\u003cp\u003eYou can take and complete at most one of these jobs in a day.\u003c/p\u003e \n\u003cp\u003eHowever, you cannot retake a job that you have already done.\u003c/p\u003e \n\u003cp\u003eFind the maximum total reward that you can earn no later than \u003cvar\u003eM\u003c/var\u003e days from today.\u003c/p\u003e \n\u003cp\u003eYou can already start working today.\u003c/p\u003e\u003cscript defer src\u003d\u0027CDN_BASE_URL/8cfcd2984d69498e59bf783c827b2a76?v\u003d1569200831\u0027\u003e\u003c/script\u003e\u003cscript defer src\u003d\u0027CDN_BASE_URL/13f1d3d8f2dd057f2be3b532be7d1e08?v\u003d1569200831\u0027\u003e\u003c/script\u003e\u003cscript defer src\u003d\u0027CDN_BASE_URL/9adada3b7739c394762887a2d7612564?v\u003d1569200831\u0027\u003e\u003c/script\u003e\u003cscript defer src\u003d\u0027CDN_BASE_URL/3814b31c146721ee901a6fd9ddd5e73f?v\u003d1569200831\u0027\u003e\u003c/script\u003e"}},{"title":"Constraints","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cul\u003e \n \u003cli\u003eAll values in input are integers.\u003c/li\u003e \n\u003cimg src\u003d\"https://latex.codecogs.com/gif.latex?\\\\1\u0026space;\\leq\u0026space;N\u0026space;\\leq\u0026space;10^5\\\\\u0026space;1\u0026space;\\leq\u0026space;M\u0026space;\\leq\u0026space;10^5\\\\\u0026space;1\u0026space;\\leq\u0026space;A_i\u0026space;\\leq\u0026space;10^5\\\\\u0026space;1\u0026space;\\leq\u0026space;B_i\u0026space;\\leq\u0026space;10^4\\\\\" /\u003e\u003c/a\u003e\n\u003c/ul\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e \n\u003ca target\u003d\"_blank\"\u003e\u003cimg src\u003d\"https://latex.codecogs.com/gif.latex?\\\\N\u0026space;M\\\\\u0026space;A_1\u0026space;B_1\\\\\u0026space;A_2\u0026space;B_2\\\\\u0026space;\\vdots\\\\\u0026space;A_N\u0026space;B_N\\\\\" /\u003e\u003c/a\u003e\n\u003c/pre\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cp\u003ePrint the maximum total reward that you can earn no later than \u003cvar\u003eM\u003c/var\u003e days from today.\u003c/p\u003e"}},{"title":"Sample Input 1","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e3 4\n4 3\n4 1\n2 2\n\u003c/pre\u003e"}},{"title":"Sample Output 1","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e5\n\u003c/pre\u003e \n\u003cp\u003eYou can earn the total reward of \u003cvar\u003e5\u003c/var\u003e by taking the jobs as follows:\u003c/p\u003e \n\u003cul\u003e \n \u003cli\u003eTake and complete the first job today. You will earn the reward of \u003cvar\u003e3\u003c/var\u003e after four days from today.\u003c/li\u003e \n \u003cli\u003eTake and complete the third job tomorrow. You will earn the reward of \u003cvar\u003e2\u003c/var\u003e after two days from tomorrow, that is, after three days from today.\u003c/li\u003e \n\u003c/ul\u003e"}},{"title":"Sample Input 2","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\u003c/pre\u003e"}},{"title":"Sample Output 2","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e10\n\u003c/pre\u003e"}},{"title":"Sample Input 3","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e1 1\n2 1\n\u003c/pre\u003e"}},{"title":"Sample Output 3","value":{"format":"HTML","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e0\n\u003c/pre\u003e"}}]}