Easy dp solution in c++.
Intuition\nDP\n\n\n# Complexity\n- Time complexity:\n O(n^2)\n\n- Space complexity:\n O(n) \n\n# Code\n\nclass Solution {\npublic:\n    int minimumTime(vector<i
# Intuition\nDP\n\n\n# Complexity\n- Time complexity:\n $$O(n^2)$$\n\n- Space complexity:\n $$O(n)$$ \n\n# Code\n```\nclass Solution {\npublic:\n    int minimumTime(vector<int>& nums1, vector<int>& nums2, int x) {\n        int n = nums1.size();\n\n        vector<pair<int,int>>pr;\n        for(int i=0;i<n;i++) pr.push_back({nums2[i],nums1[i]});\n        sort(pr.begin(),pr.end());\n\n        int sma = 0 , smb = 0;\n\n        for(auto [u,v]:pr) {\n            smb += u;\n            sma += v;\n        }\n\n        vector<int>dp(n+1);\n        \n        for(auto [b,a]:pr) {\n            for(int i=n;i>0;i--) {\n                dp[i] = max(dp[i],dp[i-1]+i*b+a);\n            }\n        }\n\n        for(int i=0;i<=n;i++) {\n            if(x >= sma+i*smb - dp[i]) return i;\n        }\n\n        return -1;\n    }\n};\n```
['C++']