{"id":358,"date":"2024-04-28T15:20:10","date_gmt":"2024-04-28T07:20:10","guid":{"rendered":"https:\/\/seanxd.com\/?p=358"},"modified":"2024-04-28T15:20:12","modified_gmt":"2024-04-28T07:20:12","slug":"zerojudge-j178","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-j178\/","title":{"rendered":"ZeroJudge J178: Mobile Game"},"content":{"rendered":"<p class=\"translation-block\">Hua-Hua often sees an advertisement for a mobile game while browsing social media apps. In the game, players control a character who continuously challenges monsters. <strong>If the player's character has a higher combat power than the monster, they can defeat the monster and absorb its combat power value<\/strong>; otherwise, <strong>if the player's character has the same or lower combat power than the monster, the player's character will die, and the game will end<\/strong>.<\/p>\n\n\n\n<p class=\"\">Please write a program that calculates the player character's combat power at the end of the game, given the combat power values of the encountered monsters in sequence.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Inputs\/Outputs<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short\"><table class=\"has-fixed-layout\"><thead><tr><th>Sample Input(s)<\/th><th>Sample Output(s)<\/th><\/tr><\/thead><tbody><tr><td class=\"translation-block\">The first line of input contains two integers, M (1 \u2264 M \u2264 300) and A (1 \u2264 A \u2264 10000), representing the number of monsters and the initial combat power of the player, respectively.\nThe second line contains M integers T<sub>i<\/sub> (1 \u2264 T<sub>i<\/sub> \u2264 6000, i = 1, 2, 3, \u2026, M), representing the combat power values of the monsters that the player will encounter in sequence.<\/td><td>Please output the combat power of Hua-Hua when the game ends.<\/td><\/tr><tr><td>5  20<br>30  60  90  120  150<\/td><td>20<\/td><\/tr><tr><td>4  32<br>31  61  91  215<\/td><td>215<\/td><\/tr><tr><td>3  10000<br>10  20  30<\/td><td>10060<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Thought Process<\/h2>\n\n\n\n<p class=\"translation-block\">Use a boolean value to determine whether combat power needs to be evaluated, initially set to True. If encountering a monster with the same or higher level, set the boolean value to False and do not evaluate combat power when collecting data thereafter.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=j178\" target=\"_blank\" rel=\"noopener\">ZeroJudge J178: Mobile Game<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int M, A;\n    cin &gt;&gt; M &gt;&gt; A;\n    bool stop = false;\n    for (int i = 0; i&lt;M; i++)\n    {\n        int tmp;\n        cin &gt;&gt; tmp;\n        if (A &gt; tmp && !stop) A += tmp;\n        else stop = true;\n    }\n    cout &lt;&lt; A &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge J178\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u83ef\u83ef\u5728\u700f\u89bd\u793e\u7fa4\u8edf\u9ad4\u6642\u7d93\u5e38\u770b\u5230\u4e00\u6b3e\u624b\u904a\u5ee3\u544a\uff0c\u904a\u6232\u5167\u5bb9\u662f\u73a9\u5bb6\u63a7\u5236\u4e00\u500b\u89d2\u8272\u4e0d\u65b7\u6311\u6230\u602a\u7269\uff0c\u53ea\u8981\u73a9\u5bb6\u89d2\u8272\u7684\u6230\u529b\u6bd4\u602a\u7269\u9ad8\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[25],"tags":[8,34,9],"class_list":["post-358","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-8","tag-34","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=358"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/358\/revisions"}],"predecessor-version":[{"id":359,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/358\/revisions\/359"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}