标签:vector 效率 优化 for iii span tor 规划 --
思路:
动态规划+转移方程效率优化。
实现:
1 class Solution 2 { 3 public: 4 int stoneGameVIII(vector<int>& stones) 5 { 6 int n = stones.size(), sum = 0; 7 for (int i = 0; i < n; i++) sum += stones[i]; 8 int x = sum; 9 for (int i = n - 2; i >= 1; i--) 10 { 11 sum -= stones[i + 1]; 12 x = max(sum - x, x); 13 } 14 return x; 15 } 16 };
标签:vector 效率 优化 for iii span tor 规划 --
原文地址:https://www.cnblogs.com/wangyiming/p/14825293.html