{"id":41,"date":"2025-01-11T22:46:51","date_gmt":"2025-01-11T14:46:51","guid":{"rendered":"http:\/\/150.230.63.147\/blog\/?p=41"},"modified":"2025-01-11T22:46:51","modified_gmt":"2025-01-11T14:46:51","slug":"b-game-of-the-rows-%e8%a7%a3%e6%9e%90%e6%80%9d%e7%b6%ad","status":"publish","type":"post","link":"https:\/\/blog.seekrealthing.net\/blog\/?p=41","title":{"rendered":"B. Game of the Rows \u89e3\u6790(\u601d\u7dad)"},"content":{"rendered":"\n<div class=\"wp-block-jetpack-markdown\"><h1>Codeforce 839 B. Game of the Rows \u89e3\u6790(\u601d\u7dad)<\/h1>\n<p>\u4eca\u5929\u6211\u5011\u4f86\u770b\u770bCF839B<br>\n<a href=\"https:\/\/codeforces.com\/problemset\/problem\/839\/B\">\u984c\u76ee\u9023\u7d50<\/a><\/p>\n<blockquote>\n<p><strong>\u984c\u76ee<\/strong><br>\n\u6709\u5982\u4e0b\u5716\u7247\u6240\u793a\u7684\u98db\u6a5f\u5ea7\u4f4d$n$\u6392\uff0c\u548c$k$\u968a\u58eb\u5175\uff0c\u6bcf\u968a\u6578\u91cf\u4e0d\u4e00\u5b9a\u3002<br>\n<img decoding=\"async\" src=\"https:\/\/i.imgur.com\/1vMRL5j.png\" alt=\"\"><br>\n\u6c42\u662f\u5426\u53ef\u4ee5\u6bcf\u968a\u90fd\u5750\u4e0a\u53bb\u4e26\u4e14\u6c92\u6709\u4efb\u4f55\u5169\u500b\u58eb\u5175\u76f8\u9130\u300c\u4e26\u4e14\u300d\u662f\u4e0d\u540c\u968a\u7684\u3002<\/p>\n<\/blockquote>\n<h3>\u524d\u8a00<\/h3>\n<p>\u601d\u8003\u6642\u5c0f\u5fc3\u4e00\u9ede\uff0c\u8a18\u5f97\u5ea7\u4f4d\u6709\u5f88\u591a\u7a2e\u6368\u68c4\u65b9\u6cd5<\/p>\n<h3>\u60f3\u6cd5<\/h3>\n<p>\u6ce8\u610f\u5230\uff0c\u5728\u5ea7\u4f4d\u8db3\u5920\u7684\u60c5\u6cc1\u4e0b\uff0c\u6211\u5011\u53ef\u4ee5\u6709\u4e09\u6b65\u9a5f\u7684\u65b9\u6cd5\u4f86\u6368\u53bb\u5ea7\u4f4d\u3002<\/p>\n<ol>\n<li>\u628a\u4e2d\u9593\u7684$4$\u500b\u5ea7\u4f4d\u5206\u6210$1,2$\u4eba\u5ea7\u4f4d (\u6b64\u6b65\u628a\u53ef\u4ee5\u5f97\u5230\u7684\u9593\u9694\u90fd\u5f97\u5230\u4e86)<\/li>\n<li>\u628a\u5de6\u53f3\u76842\u500b2\u4eba\u5ea7\u4f4d\u96a8\u4fbf\u9078\u4e00\u500b(\u6216\u8005\u5169\u500b\u90fd\u9078)\u6368\u53bb\u4e00\u500b\u5ea7\u4f4d\uff0c\u8b8a\u6210$1$\u4eba\u5ea7\u4f4d<\/li>\n<li>\u628a\u4e2d\u9593\u5df2\u7d93\u62c6\u6210$1,2$\u4eba\u5ea7\u4f4d\u76844\u500b\u5ea7\u4f4d\uff0c\u518d\u6368\u53bb\u4e00\u500b\uff0c\u8b8a\u6210$1,1$\u4eba\u5ea7\u4f4d<\/li>\n<\/ol>\n<p>($2.3.$\u5169\u500b\u6b65\u9a5f\u662f\u5728\u628a$2$\u4eba\u5ea7\u4f4d\u63db\u6210$1$\u4eba\u5ea7\u4f4d\uff0c\u9019\u6a23\u624d\u80fd\u65b9\u4fbf\u7b49\u7b49\u7684\u5206\u914d\u5ea7\u4f4d\u9806\u5229\u904b\u884c)<br>\n\u63a5\u8457\u8981\u628a\u58eb\u5175\u4e00\u968a\u4e00\u968a\u5206\u914d\u9032\u53bb\u3002\u73fe\u5728\u5df2\u7d93\u6709$1,2,4$\u4eba\u5ea7\u4f4d\u7684\u6578\u91cf\u4e86\uff0c\u800c\u9019\u4e9b\u5ea7\u4f4d\u90fd\u662f\u5206\u958b\u7684\uff0c\u90a3\u9ebc\u6211\u5011\u53ea\u8981\u5f9e\u6700\u5927\u7684\u5ea7\u4f4d\u958b\u59cb\u628a\u58eb\u5175\u5206\u914d\u9032\u53bb\u5c31\u597d\u3002<\/p>\n<h3>\u7a0b\u5f0f\u78bc:<\/h3>\n<pre><code class=\"language-cpp=\">const int _n=1e4+10;  \nint t,tt,ttt,n,k,a[_n],sum=0,cnt[5];  \nmain(void) {cin.tie(0);ios_base::sync_with_stdio(0);  \n  cin&gt;&gt;n&gt;&gt;k;rep(i,0,k){cin&gt;&gt;a[i];sum+=a[i];} cnt[2]=2*n,cnt[4]=n;  \n  t=min(n,8*n-sum); cnt[1]=t,cnt[2]+=t,cnt[4]-=t;  \n  if(t==n){tt=min(2*n,8*n-n-sum); cnt[1]+=tt,cnt[2]-=tt;}  \n  if(tt==2*n){ttt=min(n,8*n-n-n-n-sum); cnt[1]+=ttt,cnt[2]-=ttt;}  \n  rep(i,0,k){  \n    int f=min(cnt[4],a[i]\/4);  \n    cnt[4]-=f; a[i]-=4*f;  \n    f=min(cnt[2],a[i]\/2);  \n    cnt[2]-=f; a[i]-=2*f;  \n    f=min(cnt[1],a[i]);  \n    cnt[1]-=f; a[i]-=f;  \n    if(a[i]){cout&lt;&lt;&quot;NO\\n&quot;;return 0;}  \n  }cout&lt;&lt;&quot;YES\\n&quot;;  \n  return 0;  \n}  \n<\/code><\/pre>\n<p>\u6a19\u982d\u3001\u6a21\u677f\u8acb\u9edeSubmission\u770b<br>\n<a href=\"https:\/\/codeforces.com\/contest\/839\/submission\/90458994\">Submission<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[3],"tags":[10,9,8],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-ojcode","tag-codeforce","tag-ojcode","tag-8"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>B. Game of the Rows \u89e3\u6790(\u601d\u7dad) - Logic Formatting<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.seekrealthing.net\/blog\/?p=41\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"B. Game of the Rows \u89e3\u6790(\u601d\u7dad) - Logic Formatting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.seekrealthing.net\/blog\/?p=41\" \/>\n<meta property=\"og:site_name\" content=\"Logic Formatting\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-11T14:46:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i.imgur.com\/1vMRL5j.png\" \/>\n<meta name=\"author\" content=\"jeff\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005:\" \/>\n\t<meta name=\"twitter:data1\" content=\"jeff\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41\"},\"author\":{\"name\":\"jeff\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/233e80a0fee3d4706f067f2e88c0b454\"},\"headline\":\"B. Game of the Rows \u89e3\u6790(\u601d\u7dad)\",\"datePublished\":\"2025-01-11T14:46:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41\"},\"wordCount\":17,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i.imgur.com\/1vMRL5j.png\",\"keywords\":[\"codeforce\",\"ojcode\",\"\u601d\u7dad\"],\"articleSection\":[\"ojcode\"],\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blog.seekrealthing.net\/blog\/?p=41#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41\",\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41\",\"name\":\"B. Game of the Rows \u89e3\u6790(\u601d\u7dad) - Logic Formatting\",\"isPartOf\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i.imgur.com\/1vMRL5j.png\",\"datePublished\":\"2025-01-11T14:46:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.seekrealthing.net\/blog\/?p=41\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41#primaryimage\",\"url\":\"https:\/\/i.imgur.com\/1vMRL5j.png\",\"contentUrl\":\"https:\/\/i.imgur.com\/1vMRL5j.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=41#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9801\",\"item\":\"https:\/\/blog.seekrealthing.net\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"B. Game of the Rows \u89e3\u6790(\u601d\u7dad)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#website\",\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/\",\"name\":\"Logic Formatting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.seekrealthing.net\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-TW\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#organization\",\"name\":\"Logic Formatting\",\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/wp-content\/uploads\/2025\/02\/android-chrome-512x512-1.png\",\"contentUrl\":\"https:\/\/blog.seekrealthing.net\/blog\/wp-content\/uploads\/2025\/02\/android-chrome-512x512-1.png\",\"width\":512,\"height\":512,\"caption\":\"Logic Formatting\"},\"image\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/233e80a0fee3d4706f067f2e88c0b454\",\"name\":\"jeff\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f9b571b28c252728386f0002b35d9cb9a9028f740b0f9ca5ad678e7eb21c4857?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f9b571b28c252728386f0002b35d9cb9a9028f740b0f9ca5ad678e7eb21c4857?s=96&d=mm&r=g\",\"caption\":\"jeff\"},\"sameAs\":[\"http:\/\/150.230.63.147\/blog\"],\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"B. Game of the Rows \u89e3\u6790(\u601d\u7dad) - Logic Formatting","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.seekrealthing.net\/blog\/?p=41","og_locale":"zh_TW","og_type":"article","og_title":"B. Game of the Rows \u89e3\u6790(\u601d\u7dad) - Logic Formatting","og_url":"https:\/\/blog.seekrealthing.net\/blog\/?p=41","og_site_name":"Logic Formatting","article_published_time":"2025-01-11T14:46:51+00:00","og_image":[{"url":"https:\/\/i.imgur.com\/1vMRL5j.png","type":"","width":"","height":""}],"author":"jeff","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005:":"jeff","\u9810\u4f30\u95b1\u8b80\u6642\u9593":"1 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41#article","isPartOf":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41"},"author":{"name":"jeff","@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/233e80a0fee3d4706f067f2e88c0b454"},"headline":"B. Game of the Rows \u89e3\u6790(\u601d\u7dad)","datePublished":"2025-01-11T14:46:51+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41"},"wordCount":17,"commentCount":0,"publisher":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/#organization"},"image":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41#primaryimage"},"thumbnailUrl":"https:\/\/i.imgur.com\/1vMRL5j.png","keywords":["codeforce","ojcode","\u601d\u7dad"],"articleSection":["ojcode"],"inLanguage":"zh-TW","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.seekrealthing.net\/blog\/?p=41#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41","url":"https:\/\/blog.seekrealthing.net\/blog\/?p=41","name":"B. Game of the Rows \u89e3\u6790(\u601d\u7dad) - Logic Formatting","isPartOf":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41#primaryimage"},"image":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41#primaryimage"},"thumbnailUrl":"https:\/\/i.imgur.com\/1vMRL5j.png","datePublished":"2025-01-11T14:46:51+00:00","breadcrumb":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.seekrealthing.net\/blog\/?p=41"]}]},{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41#primaryimage","url":"https:\/\/i.imgur.com\/1vMRL5j.png","contentUrl":"https:\/\/i.imgur.com\/1vMRL5j.png"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=41#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9801","item":"https:\/\/blog.seekrealthing.net\/blog"},{"@type":"ListItem","position":2,"name":"B. Game of the Rows \u89e3\u6790(\u601d\u7dad)"}]},{"@type":"WebSite","@id":"https:\/\/blog.seekrealthing.net\/blog\/#website","url":"https:\/\/blog.seekrealthing.net\/blog\/","name":"Logic Formatting","description":"","publisher":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.seekrealthing.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-TW"},{"@type":"Organization","@id":"https:\/\/blog.seekrealthing.net\/blog\/#organization","name":"Logic Formatting","url":"https:\/\/blog.seekrealthing.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/blog.seekrealthing.net\/blog\/wp-content\/uploads\/2025\/02\/android-chrome-512x512-1.png","contentUrl":"https:\/\/blog.seekrealthing.net\/blog\/wp-content\/uploads\/2025\/02\/android-chrome-512x512-1.png","width":512,"height":512,"caption":"Logic Formatting"},"image":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/233e80a0fee3d4706f067f2e88c0b454","name":"jeff","image":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f9b571b28c252728386f0002b35d9cb9a9028f740b0f9ca5ad678e7eb21c4857?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f9b571b28c252728386f0002b35d9cb9a9028f740b0f9ca5ad678e7eb21c4857?s=96&d=mm&r=g","caption":"jeff"},"sameAs":["http:\/\/150.230.63.147\/blog"],"url":"https:\/\/blog.seekrealthing.net\/blog\/?author=1"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":1,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":42,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions\/42"}],"wp:attachment":[{"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}