{"id":849,"date":"2023-11-10T23:19:48","date_gmt":"2023-11-10T15:19:48","guid":{"rendered":"http:\/\/ggapa.net:81\/?p=849"},"modified":"2024-02-12T14:40:12","modified_gmt":"2024-02-12T06:40:12","slug":"%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"http:\/\/ggapa.net:81\/2023\/11\/10\/%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0\/","title":{"rendered":"\u6570\u636e\u7ed3\u6784\u5b66\u4e60\u7b14\u8bb0"},"content":{"rendered":"
\u7ebf\u6bb5\u6811\u5728\u7b97\u6cd5\u7ade\u8d5b\u4e2d\u5e38\u7528\u4e8e\u533a\u95f4\u64cd\u4f5c\u3002\u65f6\u95f4\u590d\u6742\u5ea6$O(\\log n)$\u3002<\/p>\n
\u987e\u540d\u601d\u4e49\uff0c\u533a\u95f4\u4fee\u6539\uff0c\u533a\u95f4\u67e5\u8be2\u3002<\/p>\n
\u95ee\u9898\u63cf\u8ff0\uff1a<\/p>\n
\u64cd\u4f5c\u4e00\uff1a\u8fdb\u884c\u5355\u70b9\u4fee\u6539\u3002<\/p>\n<\/li>\n
\u64cd\u4f5c\u4e8c\uff1a\u7ed9\u5b9a $l$ \u548c $r$\uff0c\u95ee $[l, r]$ \u4e2d\u7684\u6700\u5927\u7684\u5b50\u6bb5\u548c\u662f\u591a\u5c11\uff1f<\/p>\n<\/li>\n<\/ul>\n
\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u9700\u8981\u5f15\u5165\u7684\u61d2\u6807\u8bb0\u6709\u5982\u4e0b\u51e0\u4e2a<\/p>\n
\u5728\u4fee\u6539\u65f6<\/strong><\/p>\n \u5148\u66f4\u65b0 $maxv$\u3002<\/p>\n \u82e5 $maxl < 0 \\and maxr < 0$\uff08\u60c5\u51b5\u4e00\uff09\uff0c$maxv = \\max{maxl,maxr}$ \u3002\u9898\u76ee\u4e2d\u8981\u6c42\u5fc5\u987b\u8981\u53d6\u4e00\u4e2a\u5143\u7d20\uff0c\u4e0d\u80fd\u4e0d\u53d6\u3002<\/p>\n \u82e5\u60c5\u51b5\u4e00\u4e0d\u6210\u7acb\uff0c\u5219\u8bf4\u660e $maxl < 0 \\or maxr < 0$ \u4e3a\u771f\uff08\u60c5\u51b5\u4e8c\uff09\uff0c\u6b64\u65f6\u9700\u8981\u5c06 $maxv$ \u5f52 $0\uff0c\u7136\u540e\u5c06$ $maxv$ \u5c31\u53ef\u4ee5\u52a0\u4e0a $maxl,maxr$ \u4e2d\u4e3a\u6b63\u7684\u503c\u3002<\/p>\n \u4e5f\u6709\u53ef\u80fd\u4ee5\u4e0a\u7684\u60c5\u51b5\u90fd\u4e0d\u662f\u6700\u5927\u5b50\u6bb5\u548c\uff0c\u6700\u540e\u7684 $maxv = \\max{maxv,maxv(\u5de6\u513f\u5b50),maxv(\u53f3\u513f\u5b50)}$\u3002\u7279\u522b\u8bf4\u660e\uff0c\u4ee5\u4e0a\u4e24\u79cd\u60c5\u51b5\u4e2d\u7684 $maxl$ \u548c $maxr$ \u5206\u522b\u662f\u5176\u53f3\u5de6\u513f\u5b50\u7684\u4fe1\u606f\u3002<\/p>\n \u63a5\u7740\u66f4\u65b0 $maxr$ \u548c $maxl$ \u3002<\/p>\n \u56e0\u4e3a\u7ebf\u6bb5\u6811\u9700\u8981\u5408\u5e76\u4e24\u4e2a\u533a\u95f4\uff0c\u53ef\u4ee5\u5f97\u51fa $maxl$ \u4e3a\u5de6\u513f\u5b50\u7684 $maxl$ \u4e0e\u5de6\u513f\u5b50 $sumv$ \u548c\u53f3\u513f\u5b50 $maxl$ \u548c\u7684\u6700\u5927\u503c\u3002\u800c $maxr$ \u4e3a\u53f3\u513f\u5b50\u7684 $maxr$ \u4e0e\u53f3\u513f\u5b50 $sumv$ \u548c\u5de6\u513f\u5b50 $maxr$ \u7684\u6700\u5927\u503c\u3002\u8be5\u8282\u70b9\u7684 $sum$ \u4e3a\u5176\u5de6\u53f3\u513f\u5b50 $sum$ \u7684\u548c\u3002<\/p>\n \u5728\u67e5\u8be2\u65f6<\/strong><\/p>\n \u82e5\u67e5\u8be2\u533a\u95f4\u8986\u76d6\u8fd9\u4e00\u8282\u70b9\uff0c\u5219\u8fd4\u56de\u8fd9\u4e00\u8282\u70b9\u7684\u4fe1\u606f\uff1b\u82e5\u5b8c\u5168\u8986\u76d6\u4e86\u5176\u4e2d\u4e00\u4e2a\u513f\u5b50\uff0c\u5219\u8fd4\u56de\u8986\u76d6\u5230\u7684\u513f\u5b50\u7684\u4fe1\u606f\uff1b\u82e5\u6ca1\u6709\u5b8c\u5168\u8986\u76d6\u4e00\u4e2a\u513f\u5b50\uff0c\u901a\u8fc7\u5408\u5e76\u7684\u65b9\u5f0f\u67e5\u8be2\u8986\u76d6\u5230\u7684\u533a\u95f4\u3002\u6700\u540e\u8fd4\u56de\u7684 $maxv$ \u5373\u4e3a\u4e00\u6b21\u67e5\u8be2\u7684\u6700\u7ec8\u7b54\u6848\u3002<\/p>\n \u6a21\u677f\u9898\u4ee3\u7801<\/a><\/p>\n1.2.3 01 \u533a\u95f4\u7ffb\u8f6c + \u6700\u957f\u5b50\u6bb5\u548c<\/h3>\n