Tap here to switch tabs
Problem
Submissions

Problem: Maximum Profit of Operating a Centennial Wheel

med
30 min
Try to solve the Maximum Profit of Operating a Centennial Wheel problem.

Statement

A Ferris wheel has 44 gondolas, each capable of holding up to 44 passengers. The wheel rotates counterclockwise, and each rotation costs runningCost.

You are given an integer array customers of length n, where customers[i] represents the number of new customers arriving before rotation i+1i + 1. Each boarding passenger pays boardingCost.

Before each rotation, at most 44 waiting customers board the arriving gondola. Any remaining customers stay in line. The wheel can continue to rotate after all customer groups have arrived as long as there are still customers waiting to board.

You may choose to stop rotating the wheel at any point.

Return the minimum number of rotations required to achieve the maximum possible profit. If it is impossible to achieve a strictly positive profit, return −1-1.

Constraints:

  • n ==== customers.length

  • 1≤1 \le n ≤105\le 10^5

  • 0≤0 \le customers[i] ≤50\le 50

  • 1≤1 \le boardingCost, runningCost ≤100\le 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Profit of Operating a Centennial Wheel

med
30 min
Try to solve the Maximum Profit of Operating a Centennial Wheel problem.

Statement

A Ferris wheel has 44 gondolas, each capable of holding up to 44 passengers. The wheel rotates counterclockwise, and each rotation costs runningCost.

You are given an integer array customers of length n, where customers[i] represents the number of new customers arriving before rotation i+1i + 1. Each boarding passenger pays boardingCost.

Before each rotation, at most 44 waiting customers board the arriving gondola. Any remaining customers stay in line. The wheel can continue to rotate after all customer groups have arrived as long as there are still customers waiting to board.

You may choose to stop rotating the wheel at any point.

Return the minimum number of rotations required to achieve the maximum possible profit. If it is impossible to achieve a strictly positive profit, return −1-1.

Constraints:

  • n ==== customers.length

  • 1≤1 \le n ≤105\le 10^5

  • 0≤0 \le customers[i] ≤50\le 50

  • 1≤1 \le boardingCost, runningCost ≤100\le 100