class Solution {
public:
/**
* 计算你能获得的最大收益
*
* @param prices Prices[i]即第i天的股价
* @return 整型
*/
int max_second(vector<int> a,int x,int y)
{ int min1=a[x];
int max1=0;
for(int j=x;j<y;j++)
{ if(a[j]-min1>max1) max1=a[j]-min1;
if(a[j]<min1) min1=a[j];
}
return max1;
}
int calculateMax(vector<int> prices) {
int t;
int s=0;
for(int i=0;i<prices.size();i++)
{ t=max_second(prices,0,i)+max_second(prices,i,prices.size());
if(t>s) s=t;}
return s;
}
};