{"id":267,"date":"2016-11-24T11:37:02","date_gmt":"2016-11-24T03:37:02","guid":{"rendered":"http:\/\/kylelv.com\/?p=267"},"modified":"2017-12-13T13:19:03","modified_gmt":"2017-12-13T05:19:03","slug":"bzoj-3357-usaco2004%e7%ad%89%e5%b7%ae%e6%95%b0%e5%88%97","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=267","title":{"rendered":"bzoj 3357: [Usaco2004]\u7b49\u5dee\u6570\u5217"},"content":{"rendered":"<p><center><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fdef6d742a3\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fdef6d742a3\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.kylelv.com\/?p=267\/#3357_Usaco2004%E7%AD%89%E5%B7%AE%E6%95%B0%E5%88%97\" title=\"3357: [Usaco2004]\u7b49\u5dee\u6570\u5217\">3357: [Usaco2004]\u7b49\u5dee\u6570\u5217<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.kylelv.com\/?p=267\/#Description\" title=\"Description\">Description<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.kylelv.com\/?p=267\/#Input\" title=\"Input\">Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.kylelv.com\/?p=267\/#Output\" title=\"Output\">Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.kylelv.com\/?p=267\/#Sample_Input\" title=\"Sample Input\">Sample Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.kylelv.com\/?p=267\/#Sample_Output\" title=\"Sample Output\">Sample Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.kylelv.com\/?p=267\/#HINT\" title=\"HINT\">HINT<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"3357_Usaco2004%E7%AD%89%E5%B7%AE%E6%95%B0%E5%88%97\"><\/span>3357: [Usaco2004]\u7b49\u5dee\u6570\u5217<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span class=\"green\">Time Limit:\u00a010 Sec\u00a0\u00a0Memory Limit:\u00a0128 MB<\/span><\/center><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>\u00a0\u00a0\u00a0\u00a0\u7ea6\u7ff0\u53d1\u73b0\u5976\u725b\u7ecf\u5e38\u6392\u6210\u7b49\u5dee\u6570\u5217\u7684\u53f7\u7801\uff0e\u4ed6\u770b\u5230\u4e94\u5934\u725b\u6392\u6210\u8fd9\u6837\u7684\u5e8f\u53f7\uff1a\u201c1\uff0c4\uff0c3\uff0c5\uff0c7\u201d<\/div>\n<div>\u5f88\u5bb9\u6613\u770b\u51fa\u201c1\uff0c3\uff0c5\uff0c7\u201d\u662f\u7b49\u5dee\u6570\u5217\uff0e<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u7ed9\u51faN(1\u2264N\u22642000)\u6570\u5b57AI..AN(O\u2264Ai\u226410^9)\uff0c\u627e\u51fa\u6700\u957f\u7684\u7b49\u5dee\u6570\u5217\uff0c\u8f93\u51fa\u957f\u5ea6\uff0e<\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>\u00a0\u00a0\u00a0\u00a0\u7b2c1\u884c\uff1a\u4e00\u4e2a\u6574\u6570N.<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u7b2c2\u5230N+1\u884c\uff1a\u6bcf\u884c\u4e00\u4e2a\u6574\u6570Ai\uff0c\u8868\u793a\u725b\u7684\u53f7\u7801\uff0e<\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div><\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u6700\u957f\u7b49\u5dee\u6570\u5217\u7684\u957f\u5ea6\uff0e<\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Input\"><\/span>Sample Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">5<br \/>\n1<br \/>\n4<br \/>\n3<br \/>\n5<br \/>\n7<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Output\"><\/span>Sample Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">4<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre class=\"lang:c++ decode:true \">#include&lt;map&gt;\r\n#include&lt;cstdio&gt;\r\n#define M 2020\r\nusing namespace std;\r\nint n,ans,a[M];\r\nmap&lt;int,int&gt;f[M];\r\nint main()\r\n{\r\n    int i,j;\r\n    scanf(\"%d\",&amp;n);\r\n    for(i=1;i&lt;=n;i++) scanf(\"%d\",&amp;a[i]);\r\n    if(n==1)printf(\"1\");\r\n    else{\r\n    for(i=1;i&lt;=n;i++)\r\n    for(j=1;j&lt;i;j++)\r\n    {\r\n        f[i][a[j]]=max(f[i][a[j]],2);\r\n        f[i][a[j]]=max(f[i][a[j]],f[j][a[j]*2-a[i]]+1);\r\n        ans=max(ans,f[i][a[j]]);\r\n    }\r\n    printf(\"%d\",ans);}\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>3357: [Usaco2004]\u7b49\u5dee\u6570\u5217 Time Limit:\u00a010 Sec\u00a0\u00a0Memory Limit: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[5],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-dp"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=267"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":268,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions\/268"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}