{"id":969,"date":"2024-07-28T09:00:00","date_gmt":"2024-07-28T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=969"},"modified":"2024-06-21T11:36:38","modified_gmt":"2024-06-21T03:36:38","slug":"zerojudge-k570","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-k570\/","title":{"rendered":"ZeroJudge K570: Store Discounts"},"content":{"rendered":"<p>I believe a careful planner like you must know that each convenience store offers different discounts on perishable goods at different times.<br>The following is information related to promotions:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">Store Name<\/th><th class=\"has-text-align-center\" data-align=\"center\">Store ID<\/th><th class=\"has-text-align-center\" data-align=\"center\">Discount Time(s)<\/th><th class=\"has-text-align-center\" data-align=\"center\">Discount<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">LIME<\/td><td class=\"has-text-align-center\" data-align=\"center\">0<\/td><td class=\"has-text-align-center\" data-align=\"center\">18:00 &#8211; 00:00<\/td><td class=\"has-text-align-center\" data-align=\"center\">30% Off<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">Your House<\/td><td class=\"has-text-align-center\" data-align=\"center\">1<\/td><td class=\"has-text-align-center\" data-align=\"center\">10:00 &#8211; 17:00 \/ 17:00 &#8211; 00:00<\/td><td class=\"has-text-align-center\" data-align=\"center\">30% Off<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-4<\/td><td class=\"has-text-align-center\" data-align=\"center\">2<\/td><td class=\"has-text-align-center\" data-align=\"center\">10:00 &#8211; 17:00 \/ 20:00 &#8211; 00:00<\/td><td class=\"has-text-align-center\" data-align=\"center\">35% Off<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">No Prob<\/td><td class=\"has-text-align-center\" data-align=\"center\">3<\/td><td class=\"has-text-align-center\" data-align=\"center\">16:30 &#8211; 22:30<\/td><td class=\"has-text-align-center\" data-align=\"center\">40% Off<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"translation-block\">Given N transaction records,\n<br>\nEach transaction record is represented as {id, h, m, a}, where:\n<br>\nid: convenience store ID\n<br>\nh: purchase hour\n<br>\nm: purchase minute\n<br>\na: original price of the purchased item\n<br>\nYou can assume that as long as it is within the promotion period of the convenience store, only discounted perishable items will be purchased.\n<br>\nPlease help calculate the total actual consumption amount after the discount for N transaction records. For each transaction, <strong>round down the decimal point<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Inputs\/Outputs<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Sample Input(s)<\/th><th>Sample Output(s)<\/th><\/tr><\/thead><tbody><tr><td>The first line contains a positive integer N, indicating the number of transaction details.<br>1 \u2264 N \u2264 1000<br>Then, there are N lines, each containing four integers id, h, m, a.<br>They represent the convenience store ID, the purchase hour, the purchase minute, and the original price of the purchased item, respectively.<br>0 \u2264 id \u2264 3<br>0 \u2264 h \u2264 23<br>0 \u2264 m \u2264 59<br>0 \u2264 a \u2264 1000<\/td><td class=\"translation-block\">The total actual consumption amount after the discount should be calculated. For each transaction, <strong>round down the decimal point<\/strong>.<\/td><\/tr><tr><td>4<br>0 19 30 100<br>1 19 30 100<br>2 19 30 100<br>3 19 30 100<\/td><td>300<\/td><\/tr><tr><td>2<br>0 0 0 100<br>3 16 0 100<\/td><td>170<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge K570 Sample Test Cases<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Thought Process<\/h2>\n\n\n\n<p>Convert the current time to the unit of \"minutes\" and also convert the discount period into \"minutes\" when using conditional statements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=k570\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge K570: Store Discounts<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><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 N, ans = 0;\n    cin &gt;&gt; N;\n    for (int i = 0; i&lt;N; i++) {\n        int id, h, m, a;\n        cin &gt;&gt; id &gt;&gt; h &gt;&gt; m &gt;&gt; a;\n        int min = m + (h*60);\n        if (id == 0) {\n            if (min &gt;= 1080 || min == 0) ans += a*0.7;\n            else ans += a;\n            continue;\n        }\n        if (id == 1) {\n            if (min &gt;= 600 || min == 0) ans += a*0.7;\n            else ans += a;\n            continue;\n        }\n        if (id == 2) {\n            if ((min &gt;= 600 && min &lt;= 1020) || min &gt;= 1200 || min == 0) ans += a*.65;\n            else ans += a;\n            continue;\n        }\n\n        if (min &gt;= 990 && min &lt;= 1350) ans += a*.6;\n        else ans += a;\n    }\n    cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge K570\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u76f8\u4fe1\u7cbe\u6253\u7d30\u7b97\u7684\u4f60\u4e00\u5b9a\u77e5\u9053\uff0c\u6bcf\u5bb6\u8d85\u5546\u5728\u4e0d\u540c\u6642\u6bb5\u6703\u63d0\u4f9b\u4e0d\u540c\u5373\u671f\u54c1\u512a\u60e0\u3002\u4ee5\u4e0b\u662f\u512a\u60e0\u76f8\u95dc\u8cc7\u8a0a\uff1a \u8d85\u5546\u540d\u7a31 \u8d85\u5546\u7de8\u865f \u512a [&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":[29],"tags":[8,13,9],"class_list":["post-969","post","type-post","status-publish","format-standard","hentry","category-zerojudge-","tag-8","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/969","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=969"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/969\/revisions"}],"predecessor-version":[{"id":971,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/969\/revisions\/971"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}