Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Numbers Non-positive

med
30 min
Try to solve the Minimum Operations to Make Numbers Non-positive problem.

Statement

You are given an integer array nums and two integers x and y.

In each operation, you can select an index i such that 0≤0 \leq i << nums.length and perform the following:

  • Decrease nums[i] by x.

  • Decrease all other elements in nums by y.

Return the minimum number of operations required to make every value in nums less than or equal to 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq y << x ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Numbers Non-positive

med
30 min
Try to solve the Minimum Operations to Make Numbers Non-positive problem.

Statement

You are given an integer array nums and two integers x and y.

In each operation, you can select an index i such that 0≤0 \leq i << nums.length and perform the following:

  • Decrease nums[i] by x.

  • Decrease all other elements in nums by y.

Return the minimum number of operations required to make every value in nums less than or equal to 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq y << x ≤109\leq 10^9