{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e 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","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eYou are given an array of length \u003ci\u003eN\u003c/i\u003e and \u003ci\u003eQ\u003c/i\u003e queries. Each query contains \u003ci\u003el\u003c/i\u003e and \u003ci\u003er\u003c/i\u003e. Your task is to find a contiguous subsequence between \u003ci\u003el\u003c/i\u003e and \u003ci\u003er\u003c/i\u003e such that, when excluding the duplicates, the sum is maximized. Note that the subsequence can be empty.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":" \u003cul\u003e \n \u003cli\u003eLine 1: integer \u003ci\u003eN\u003c/i\u003e (1 \u0026lt;\u003d \u003ci\u003eN\u003c/i\u003e \u0026lt;\u003d 100000); \u003c/li\u003e\n \u003cli\u003eLine 2: \u003ci\u003eN\u003c/i\u003e integers in the range [-100000, 100000]; \u003c/li\u003e\n \u003cli\u003eLine 3: integer \u003ci\u003eQ\u003c/i\u003e (1 \u0026lt;\u003d \u003ci\u003eQ\u003c/i\u003e \u0026lt;\u003d 100000); \u003c/li\u003e\n \u003cli\u003eLine 3+\u003ci\u003ei\u003c/i\u003e (1 \u0026lt;\u003d \u003ci\u003ei\u003c/i\u003e \u0026lt;\u003d \u003ci\u003eQ\u003c/i\u003e): two integers \u003ci\u003el\u003c/i\u003e and \u003ci\u003er\u003c/i\u003e denoting the \u003ci\u003ei\u003c/i\u003eth question. \u003c/li\u003e\n \u003c/ul\u003e "}},{"title":"Output","value":{"format":"HTML","content":" \u003cul\u003e \n \u003cli\u003eLine \u003ci\u003ei\u003c/i\u003e: a single integer, the answer to the \u003ci\u003ei\u003c/i\u003eth question. \u003c/li\u003e\n \u003c/ul\u003e "}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\n9\n4 -2 -2 3 -1 -4 2 2 -6\n4\n1 2\n1 5\n2 3\n4 9\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\n4\n5\n0\n3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}