cswork / OAOpen practice workspace

GreyOrangeOA #2

Array Operations

Estimated MediumStatement and editorial — judging is being prepared

Topics (AI-labelled)Binary SearchGreedy

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.

Example 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.

Editorial

Loading solution…