From 42f7e2d10806dd5c6387aa5e250e6656ced5a889 Mon Sep 17 00:00:00 2001 From: mhrooz Date: Mon, 1 Jan 2024 12:32:38 +0800 Subject: [PATCH] 1599 simple math --- 1599-240101-pass/main.cpp | 77 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 1599-240101-pass/main.cpp diff --git a/1599-240101-pass/main.cpp b/1599-240101-pass/main.cpp new file mode 100644 index 0000000..9c82e6a --- /dev/null +++ b/1599-240101-pass/main.cpp @@ -0,0 +1,77 @@ +#include +using namespace std; +class Solution { +public: + int minOperationsMaxProfit(vector& customers, int boardingCost, int runningCost) { + if(boardingCost * 4 < runningCost) return -1; + int waiting = 0; + int profit = 0; + int max_profit= -1; + int wheel = 0; + int ans = wheel; + for(int i = 0 ; i < customers.size();i++){ + waiting += customers[i]; + if(waiting <= 4){ + profit += waiting * boardingCost - runningCost; + waiting = 0; + }else{ + profit += 4 * boardingCost - runningCost; + waiting -= 4; + } + cout< customer_ex1 = {8,3}; + int boardingCost = 5, runningCost = 6; + cout< customer_ex2 = {10,9,6}; + boardingCost = 6, runningCost = 4; + cout< customer_ex3 = {3,4,0,5,1}; + boardingCost = 1, runningCost = 92; + cout< customer_ex4 = {2}; + boardingCost = 2, runningCost = 4; + cout<