From 6360e80430bec5f648bf242ef1a2871a938d7189 Mon Sep 17 00:00:00 2001 From: hengzzha <80679845+hengzzha@users.noreply.github.com> Date: Fri, 2 Jul 2021 15:20:36 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E5=8A=A8=E6=80=81=E8=A7=84=E5=88=92-?= =?UTF-8?q?=E8=82=A1=E7=A5=A8=E9=97=AE=E9=A2=98=E6=80=BB=E7=BB=93=E7=AF=87?= =?UTF-8?q?.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\256\351\242\230\346\200\273\347\273\223\347\257\207.md" | 6 ++++++ 1 file changed, 6 insertions(+) diff --git "a/problems/\345\212\250\346\200\201\350\247\204\345\210\222-\350\202\241\347\245\250\351\227\256\351\242\230\346\200\273\347\273\223\347\257\207.md" "b/problems/\345\212\250\346\200\201\350\247\204\345\210\222-\350\202\241\347\245\250\351\227\256\351\242\230\346\200\273\347\273\223\347\257\207.md" index cac77b65d6..d22132c044 100644 --- "a/problems/\345\212\250\346\200\201\350\247\204\345\210\222-\350\202\241\347\245\250\351\227\256\351\242\230\346\200\273\347\273\223\347\257\207.md" +++ "b/problems/\345\212\250\346\200\201\350\247\204\345\210\222-\350\202\241\347\245\250\351\227\256\351\242\230\346\200\273\347\273\223\347\257\207.md" @@ -381,6 +381,12 @@ dp[i][1] = max(dp[i - 1][1], dp[i - 1][3]); dp[i][2] = dp[i - 1][0] + prices[i]; dp[i][3] = dp[i - 1][2]; ``` +```C++ +dp[i][0] = max(dp[i - 1][0], max(dp[i - 1][3]- prices[i], dp[i - 1][1]) - prices[i]; +dp[i][1] = max(dp[i - 1][1], dp[i - 1][3]); +dp[i][2] = dp[i - 1][0] + prices[i]; +dp[i][3] = dp[i - 1][2]; +``` 整体代码如下: