模拟
class Solution {
public int minOperationsMaxProfit(int[] customers, int boardingCost, int runningCost) {
int minOperation = -1;
int maxProfit = 0;
int profit = 0;
int waitedCustomers = 0;
int operation = 0;
while (true) {
if (operation >= customers.length && waitedCustomers <= 0) break;
if (operation < customers.length) waitedCustomers += customers[operation];
++operation;
int curr = waitedCustomers > 4 ? 4 : waitedCustomers;
waitedCustomers -= curr;
profit = profit + curr * boardingCost - runningCost;
if (profit > maxProfit) {
minOperation = operation;
maxProfit = profit;
}
}
return minOperation;
}
}