Python | DP | Concise Solution | O(n^2)
Code\n\nclass Solution:\n    def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:\n        sum1 = sum(nums1)\n        sum2 = sum(nums2)\n  
# Code\n```\nclass Solution:\n    def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:\n        sum1 = sum(nums1)\n        sum2 = sum(nums2)\n        nums = sorted(list(zip(nums2, nums1)))\n        n = len(nums)\n        dp = [0]*(n+1)\n        for i in range(n):\n            for k in range(i+1, 0, -1):\n                dp[k] = max(dp[k], dp[k-1] + nums[i][0]*k + nums[i][1])\n        for k in range(n+1):\n            if sum1 + k*sum2 -dp[k] <= x:\n                return k \n        return -1\n\n\n\n```
['Python3']