Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Make Array Sum At Most x

med
30 min
Try to solve the Minimum Time to Make Array Sum At Most x problem.

Statement

You are given two 00 indexed integer arrays nums1 and nums2 of the same length, along with an integer x.

In each second, you perform the following steps:

  1. For every index i, the value of nums1[i] is incremented by nums2[i].

  2. After the increment, you can select at most one index i and set nums1[i] to 00.

Return the minimum number of seconds needed to make the sum of all elements in nums1 less than or equal to x. If it is impossible to do so, return −1-1.

Constraints:

  • 1≤1 \leq nums1.length ≤103\leq 10^3

  • 1≤1 \leq nums1[i] ≤103\leq 10^3

  • 0≤0 \leq nums2[i] ≤103\leq 10^3

  • nums1.length ==== nums2.length

  • 0≤0 \leq x ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Make Array Sum At Most x

med
30 min
Try to solve the Minimum Time to Make Array Sum At Most x problem.

Statement

You are given two 00 indexed integer arrays nums1 and nums2 of the same length, along with an integer x.

In each second, you perform the following steps:

  1. For every index i, the value of nums1[i] is incremented by nums2[i].

  2. After the increment, you can select at most one index i and set nums1[i] to 00.

Return the minimum number of seconds needed to make the sum of all elements in nums1 less than or equal to x. If it is impossible to do so, return −1-1.

Constraints:

  • 1≤1 \leq nums1.length ≤103\leq 10^3

  • 1≤1 \leq nums1[i] ≤103\leq 10^3

  • 0≤0 \leq nums2[i] ≤103\leq 10^3

  • nums1.length ==== nums2.length

  • 0≤0 \leq x ≤106\leq 10^6