#include #include #include #include using namespace std;int maxProfitWithTwoTransactions(const std::vector& prices) { int n = prices.size(); if (n std::vector left(n, 0); std::vector right(n, 0); int minPrice = prices[0]; for (int i = 1; i minPrice = std::min(minPrice, prices[i]);//状态1:以低价买入 left[i] = std::max(left[i - 1], prices[i] - minPrice);//状态2:如果存在利润,则卖出(完成了一次交易),否则持有(状态3) } int maxPrice = prices[n - 1]; for (int i = n - 2; i >= 0; --i) { maxPrice = std::max(maxPrice, prices[i]);//状态4:第二次买入 right[i] = std::max(right[i + 1], maxPrice - prices[i]);//状态5:如果存在利润,则卖出,否则持有(状态3) } int maxProfit = 0; for (int i = 0; i maxProfit = std::max(maxProfit, left[i] + right[i]); } return maxProfit;}int main() { int n; cin >> n; vectorprice(n, 0); for (int i = 0; i cin >> price[i]; } cout return 0;}这是怎么能运行的??我的注释不一定对,可以忽略#C++笔试题##C++面试题##C++##C++刷题#