题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/description/
DP还没入门吧,过一段时间再来嘲笑现在的水平(逃
class Solution {
public:
int maxProfit(vector<int>& prices, int fee) {
//s0 手上一直没有股票的最大值
//s1 手上一直有一支股票的最大值
int s0 = 0, s1 = INT_MIN;
for (int p : prices) {
int tmp = s0;
s0 = max(s0, s1 + p);//这一轮卖出
s1 = max(s1, tmp - p - fee);//这一轮买入
}
return s0;
}
};