Skip to content

Commit 09e6ea1

Browse files
authored
Create Readme.md
1 parent d4bfd5b commit 09e6ea1

File tree

1 file changed

+9
-0
lines changed
  • Dynamic_Programming/2786.Visit-Array-Positions-to-Maximize-Score

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### 2786.Visit-Array-Positions-to-Maximize-Score
2+
3+
令dp[i][j]表示前i个元素里能够得到的最大值,并且最后一个元素的奇偶性是j。
4+
5+
当第i个元素不取时,dp[i][j] = dp[i-1][j]
6+
7+
当第i个元素取时,查看它的奇偶性,dp[i][j]根据j的奇偶性与nums[i]奇偶性的差异,决定是否减去x的代价。
8+
9+
最终答案是dp[n-1][0]和dp[n-1][1]的较大值。

0 commit comments

Comments
 (0)