class Solution {
public:
int minOperationsMaxProfit(vector<int>& c, int boardingCost, int runningCost) {
int wait = 0, val = 0;
int i = 0, n = c.size();
int res = -1;
while (wait || i < n) {
if (i < n) wait += c[i];
int up = min(4, wait);//这个up用得秒
wait -= up;
i ++ ;
val += up * boardingCost - runningCost;
if (val > 0) {
val = 0;
res = i;
}
}
return res;
}
};