FastPrepFastPrep
Problem Brief

Array Operations

OA

You are given an array of n elements and two variables, x and y.

In each operation, you can:

  • Subtract x from one element of the array.
  • Subtract y from the remaining elements.
  • Your task is to find the minimum number of operations required to make every element of the array ≤ 0.

    Input Format:

  • The first line contains an integer n, the number of elements in the array.
  • The second line contains n space-separated integers representing the array.
  • The third line contains two integers, x and y, where x > y.
  • Output:

    Print the minimum number of operations to make each element ≤ 0.

    1Example 1

    Input
    arr = [10, 20, 30, 40, 50], x = 5, y = 2
    Output
    13
    Explanation
    To make every element ≤ 0, the minimum number of operations required is 13.

    Constraints

    Limits and guarantees your solution can rely on.

    🍊🍊
    public int minOperations(int[] arr, int x, int y) {
      // write your code here
    }
    
    Input

    arr

    [10, 20, 30, 40, 50]

    x

    5

    y

    2

    Output

    13

    Sign in to submit your solution.