若P[k]>=P[k-1]那么在k-1时选择不卖出,否则卖出
class Solution {
public:
int maxProfit(vector<int>& prices) {
prices.push_back(0);
int m=prices[0],ans=0;
for(int k=1;k<prices.size();++k)
if(prices[k]<prices[k-1])
ans+=(prices[k-1]-m),m=prices[k];
return ans;
}
};