python n2 dynamic programming
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nn^2\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nn\n# Code\n```\nclass Solution:\n    def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:\n        myl = [(v2, v1) for v1, v2 in zip(nums1, nums2)]\n        myl.sort()\n        initial = sum(nums1)\n        add = sum(nums2)\n        myl.sort()\n        t = 0\n        if initial <= x:\n            return t\n        n = len(myl)\n        mem = [0] * n\n        while t < n:\n            t += 1\n            newmem = [0] * n\n            if t == 1:\n                newmem[0] = myl[0][0] + myl[0][1]\n            for i in range(1, n):\n                a, v = myl[i]\n                newmem[i] = max(newmem[i-1], mem[i-1]+(v + a*t))\n            if initial + add * t - newmem[-1] <= x:\n                return t\n            mem = newmem\n        return -1\n```
['Dynamic Programming', 'Python3']