{"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":"\u003cdiv id\u003d\"problem-body\"\u003e\n \u003cp\u003eYou are a daring treasure hunter embarking on a quest to find valuable artifacts on a long-forgotten island. Your exploration will be challenging, and you can only carry one backpack with you, which has a limited capacity denoted by S (1 \u003c\u003d S \u003c\u003d 2000). However, you have gathered information about N (1 \u003c\u003d N \u003c\u003d 2000) precious artifacts scattered across the island.\n\nEach artifact is unique and comes with its size and value. The size represents how much space it will occupy in your backpack, while the value denotes its worth in terms of gold coins. Unfortunately, you won\u0027t be able to carry all the artifacts due to the limited space, so you must carefully choose the ones that will yield the highest total value.\n\nYour ultimate goal is to maximize the total value of all the artifacts you decide to bring back from the island.\u003c/p\u003e\n \u003ch3\u003eInput\u003c/h3\u003e\n \u003cp\u003eThe first line contains two integers, S and N, representing the capacity of your backpack and the total number of artifacts on the island, respectively. The next N lines each contain two integers, size, and value, describing one artifact per line.\u003c/p\u003e\n \u003ch3\u003eOutput\u003c/h3\u003e\n \u003cp\u003eYou should output a single integer, which represents the maximum total value you can achieve by selecting the best combination of artifacts for your treasure hunting adventure.\u003c/p\u003e\n \u003ch3\u003eExample\u003c/h3\u003e\n \u003cpre\u003e\n\u003cb\u003eInput:\u003c/b\u003e\n4 5\n1 8\n2 4\n3 0\n2 5\n2 3\n\n\n\u003cb\u003eOutput:\u003c/b\u003e\n13\n\u003c/pre\u003e\n\u003c/div\u003e"}}]}